lvgl / lv_lib_png

PNG decoder for LVGL
MIT License
67 stars 26 forks source link

fix bug: when the picture is bad it will cause double free #18

Closed jianjunxia closed 3 years ago

kisvegabor commented 3 years ago

Thank you!

jianjunxia commented 3 years ago

Thank you!

In addition, I have another question to ask. When the content of a picture is bad, do we have some kind of verification or clarification mechanism?,This is an important question for me

kisvegabor commented 3 years ago

Do you mean if the content of the image is broken?

jianjunxia commented 3 years ago

Do you mean if the content of the image is broken? Yes, I observe that I will keep opening this picture

kisvegabor commented 3 years ago

Would you expect to somehow mark the image as broken to ignore it immediately in the decoder_open function?

jianjunxia commented 3 years ago

yes,and does not affect the operation of the entire system and the use of other images

---Original--- From: "Gabor @.> Date: Wed, Jul 7, 2021 23:07 PM To: @.>; Cc: @.**@.>; Subject: Re: [lvgl/lv_lib_png] fix bug: when the picture is bad it will cause double free (#18)

Would you expect to somehow mark the image as broken to ignore it immediately in the decoder_open function?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

jianjunxia commented 3 years ago

yes,and does not affect the operation of the entire system and the use of other images

---Original--- From: "Gabor @.> Date: Wed, Jul 7, 2021 23:07 PM To: @.>; Cc: @.**@.>; Subject: Re: [lvgl/lv_lib_png] fix bug: when the picture is bad it will cause double free (#18)

Would you expect to somehow mark the image as broken to ignore it immediately in the decoder_open function?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

kisvegabor commented 3 years ago

There is no such mechanism in LVGL at this moment.

What is the use case when a PNG can be broken (incorrectly encoded)?

jianjunxia commented 3 years ago

There is no such mechanism in LVGL at this moment.

What is the use case when a PNG can be broken (incorrectly encoded)?

this is my test code:

#define TY_IMG_TEST "S:" TY_IMG_PATH "bad.png"
STATIC OPERATE_RET  gui_socket_set_img(lv_obj_t *obj)
{
    lv_obj_t *socket_img=lv_img_create(obj,NULL);
    lv_img_set_src(socket_img, TY_IMG_TEST);
    lv_obj_align(socket_img, NULL, LV_ALIGN_CENTER,0, 0);
    return OPRT_OK;
}

Because there is no picture security and bottoming mechanism, we are worried that our pictures are bad, which will affect our system,At present, our equipment is already in production, if the picture is broken, it will cause our equipment to crash

Can this problem be solved or circumvented by adjusting the current code sequence?

kisvegabor commented 3 years ago

What if you try to open the image with lv_img_decoder_open before setting it in lv_img_set_src? If it's incorrect you can set a placeholder image instead.

jianjunxia commented 3 years ago

What if you try to open the image with lv_img_decoder_open before setting it in lv_img_set_src? If it's incorrect you can set a placeholder image instead.

set a placeholder image instead. What does that mean?

embeddedt commented 3 years ago

You can convert an image that says "Error" or something similar on it, and pass it to lv_img_set_src if lv_img_decoder_open fails.

jianjunxia commented 3 years ago

You can convert an image that says "Error" or something similar on it, and pass it to lv_img_set_src if lv_img_decoder_open fails.

OK, I will try it tomorrow. I will consult you if I have any questions. Thanks for your answers