-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(freetype): fix using memfs to create a FT font #5627
Conversation
lv_freetype_req_face_id drops path metadata when using memfs Signed-off-by: Hatim-Pierre FAZILEABASSE <hatim-pierre.fazileabasse@ingenico.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Please run the code-format.py
in the scripts
directory and then commit the formated file.
LV_ASSERT_MALLOC(node->pathname); | ||
strcpy(node->pathname, pathname); | ||
memcpy(node->pathname, pathname, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use lv_strdup
, and you can remove lv_malloc
and LV_ASSERT_MALLOC
https://github.com/lvgl/lvgl/blob/master/src/stdlib/builtin/lv_string_builtin.c#L209
See example usage: https://github.com/lvgl/lvgl/blob/master/src/draw/lv_image_decoder.c#L241
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @PGNetHun ,
Actually this can't be used here because when you use memfs the path is actually a pointer to a lv_fs_path_ex_t
object. The first field of this structure is a null terminated string.
When cast to char *
subsequent use of strlen will only copy the first field of the structure thus leading to the loss of the relevant metadata for proper use of memfs.
I hope that clears out why I used this hack on len
and malloc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense.
please fix C code formatting issue |
Signed-off-by: Hatim-Pierre FAZILEABASSE <hatim-pierre.fazileabasse@ingenico.com>
LV_ASSERT_MALLOC(node->pathname); | ||
strcpy(node->pathname, pathname); | ||
memcpy(node->pathname, pathname, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of the feature or fix
lv_freetype_req_face_id drops path metadata when using memfs,
fix uses drive letter to adjust malloc/memcpy length when creating
the cache node.
To reproduce:
in lv_conf.h : #define LV_FREETYPE_USE_LVGL_PORT 1, #define LV_USE_FREETYPE 1, LV_USE_FS_MEMFS 1
snippet:
Result:
Program will most likely crash due to OOB memory accesses when trying to use path metadata.
Notes
lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py
(astyle needs to be installed) and follow the Code Conventions