You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a memory safety issue, since get_text returns a &'static str, as it directly points to the label's text buffer, assuming the string is valid UTF-8.
However, when the label text is modified in LVGL, LVGL likely reallocates the buffer, invalidating the pointer/reference—this behavior contradicts the static reference lifetime.
To address this, the function should either be marked as unsafe (with appropriate documentation) or return an owned string instead. For instance:
We need to identify methods that return pointers so we either document them as unsafe or handle them properly. This might be possible by using the #191 request where adding support for generation of methods that return something is being handled.
Yes, that can be easily identified with syn::Type::Ptr. These should follow the same rules :
Try with zero copy / reference and safe way.
If not possible (eg label text where the lifetime is not guaranteed ), do it the unsafe way (zero copy). And maybe propose a safe with copy alternative
This is a memory safety issue, since
get_text
returns a&'static str
, as it directly points to the label's text buffer, assuming the string is valid UTF-8.However, when the label text is modified in LVGL, LVGL likely reallocates the buffer, invalidating the pointer/reference—this behavior contradicts the
static
reference lifetime.To address this, the function should either be marked as unsafe (with appropriate documentation) or return an owned string instead. For instance:
Originally posted by @AlixANNERAUD in #162 (comment)
The text was updated successfully, but these errors were encountered: