mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
fix(checkbox | label): fix string copy error (#4120)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
parent
f2b161ed57
commit
690b1bc1c4
@ -70,16 +70,16 @@ void lv_checkbox_set_text(lv_obj_t * obj, const char * txt)
|
|||||||
lv_checkbox_t * cb = (lv_checkbox_t *)obj;
|
lv_checkbox_t * cb = (lv_checkbox_t *)obj;
|
||||||
|
|
||||||
if(NULL != txt) {
|
if(NULL != txt) {
|
||||||
size_t len = 0;
|
size_t len;
|
||||||
|
|
||||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||||
len = _lv_txt_ap_calc_bytes_cnt(txt);
|
len = _lv_txt_ap_calc_bytes_cnt(txt) + 1;
|
||||||
#else
|
#else
|
||||||
len = lv_strlen(txt);
|
len = lv_strlen(txt) + 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!cb->static_txt) cb->txt = lv_realloc(cb->txt, len + 1);
|
if(!cb->static_txt) cb->txt = lv_realloc(cb->txt, len);
|
||||||
else cb->txt = lv_malloc(len + 1);
|
else cb->txt = lv_malloc(len);
|
||||||
|
|
||||||
LV_ASSERT_MALLOC(cb->txt);
|
LV_ASSERT_MALLOC(cb->txt);
|
||||||
if(NULL == cb->txt) return;
|
if(NULL == cb->txt) return;
|
||||||
|
@ -1281,8 +1281,8 @@ static void copy_text_to_label(lv_label_t * label, const char * text)
|
|||||||
#if LV_USE_ARABIC_PERSIAN_CHARS
|
#if LV_USE_ARABIC_PERSIAN_CHARS
|
||||||
_lv_txt_ap_proc(text, label->text);
|
_lv_txt_ap_proc(text, label->text);
|
||||||
#else
|
#else
|
||||||
size_t len = lv_strlen(text);
|
size_t len = lv_strlen(text) + 1;
|
||||||
(void) lv_strncpy(label->text, text, len);
|
lv_memcpy(label->text, text, len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user