mirror of
https://github.com/lvgl/lvgl.git
synced 2025-02-04 07:13:00 +08:00
fix(dropdown): avoid partial match in lv_dropdown_get_option_index (#4598)
This commit is contained in:
parent
ff4f3f9769
commit
14e21d27fb
@ -407,12 +407,16 @@ int32_t lv_dropdown_get_option_index(lv_obj_t * obj, const char * option)
|
||||
const char * opts = lv_dropdown_get_options(obj);
|
||||
uint32_t char_i = 0;
|
||||
uint32_t opt_i = 0;
|
||||
uint32_t option_len = strlen(option);
|
||||
const char * start = opts;
|
||||
|
||||
while(start[char_i] != '\0') {
|
||||
for(char_i = 0; (start[char_i] != '\n') && (start[char_i] != '\0'); char_i++);
|
||||
|
||||
if(memcmp(start, option, LV_MIN(strlen(option), char_i)) == 0) return opt_i;
|
||||
if(option_len == char_i && memcmp(start, option, LV_MIN(option_len, char_i)) == 0) {
|
||||
return opt_i;
|
||||
}
|
||||
|
||||
start = &start[char_i];
|
||||
if(start[0] == '\n') start++;
|
||||
char_i = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user