fix(indev): fix use after free of last hovered object (#6405)

This commit is contained in:
Niklas Fiekas 2024-06-23 12:54:21 +02:00 committed by GitHub
parent 2d7a9ac232
commit eff59f7bba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View File

@ -537,6 +537,9 @@ static void obj_delete_core(lv_obj_t * obj)
if(indev->pointer.last_pressed == obj) {
indev->pointer.last_pressed = NULL;
}
if(indev->pointer.last_hovered == obj) {
indev->pointer.last_hovered = NULL;
}
}
if(indev->group == group && obj == lv_indev_get_active_obj()) {

View File

@ -81,14 +81,16 @@ void test_hover_basic(void)
void test_hover_delete(void)
{
lv_obj_t * button = lv_button_create(lv_screen_active());
lv_obj_set_size(button, 200, 100);
for(int i = 0; i < 4; i++) {
lv_obj_t * btn = lv_button_create(lv_screen_active());
lv_obj_set_size(btn, 200, 100);
lv_test_indev_wait(50);
lv_test_mouse_move_to(50, 50);
lv_test_indev_wait(50);
lv_obj_delete(button); /*No crash while deleting the hovered button*/
lv_test_indev_wait(50);
lv_test_mouse_move_to(i * 10, 50);
lv_test_indev_wait(50);
lv_obj_delete(btn); /*No crash while deleting the hovered button*/
lv_test_indev_wait(50);
}
}