Image header : bad "duplicate"

Description

File : lv_image.c

Function : lv_image_set_src

Line : 213

Issue : calling lv_strdup to duplicate an image header.

That function first gets the size of the block by calling lv_strlen…which looks for a NULL character.

So…that means the image header cannot have any zeroed field…under the risk of getting a partial “duplication”.

(actually, it cannot even have a byte zero in the image map address)

Unfortunately EEZ-Studio sets the field “Flags” (in the image descriptor) to zero…which triggers the issue.

Solution

replacing :

      char * new_str = lv_strdup(src);

for :

      char * new_str = lv_malloc(sizeof(lv_image_dsc_t));
      if (new_str) { lv_memcpy(new_str, src, sizeof(lv_image_dsc_t)); }

What LVGL version are you using?

9.2