mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 11:57:48 +08:00
fix(file_explorer): table cell use after free (#7239)
This commit is contained in:
@@ -647,6 +647,8 @@ static void strip_ext(char * dir)
|
|||||||
|
|
||||||
static void exch_table_item(lv_obj_t * tb, int16_t i, int16_t j)
|
static void exch_table_item(lv_obj_t * tb, int16_t i, int16_t j)
|
||||||
{
|
{
|
||||||
|
if(i == j) return;
|
||||||
|
|
||||||
const char * tmp;
|
const char * tmp;
|
||||||
tmp = lv_table_get_cell_value(tb, i, 0);
|
tmp = lv_table_get_cell_value(tb, i, 0);
|
||||||
lv_table_set_cell_value(tb, 0, 2, tmp);
|
lv_table_set_cell_value(tb, 0, 2, tmp);
|
||||||
@@ -690,9 +692,10 @@ static void sort_by_file_kind(lv_obj_t * tb, int16_t lo, int16_t hi)
|
|||||||
int16_t gt = hi;
|
int16_t gt = hi;
|
||||||
const char * v = lv_table_get_cell_value(tb, lo, 1);
|
const char * v = lv_table_get_cell_value(tb, lo, 1);
|
||||||
while(i <= gt) {
|
while(i <= gt) {
|
||||||
if(lv_strcmp(lv_table_get_cell_value(tb, i, 1), v) < 0)
|
int strcmp_result = lv_strcmp(lv_table_get_cell_value(tb, i, 1), v);
|
||||||
|
if(strcmp_result < 0)
|
||||||
exch_table_item(tb, lt++, i++);
|
exch_table_item(tb, lt++, i++);
|
||||||
else if(lv_strcmp(lv_table_get_cell_value(tb, i, 1), v) > 0)
|
else if(strcmp_result > 0)
|
||||||
exch_table_item(tb, i, gt--);
|
exch_table_item(tb, i, gt--);
|
||||||
else
|
else
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
Reference in New Issue
Block a user