1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(layout): workaround overflow by implementing a recursion threshold (#1986)

* fix(layout): workaround overflow by implementing a recursion threshold

* Update CHANGELOG.md
This commit is contained in:
embeddedt 2021-01-04 03:55:13 -05:00 committed by GitHub
parent 3dbee9b584
commit 26ab373b43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 135 additions and 121 deletions

View File

@ -14,6 +14,7 @@
- fix(textarea) buffer overflow in password mode with UTF-8 characters - fix(textarea) buffer overflow in password mode with UTF-8 characters
- fix(textarea) cursor position after hiding character in password mode - fix(textarea) cursor position after hiding character in password mode
- fix(linemeter) draw critical lines with correct color - fix(linemeter) draw critical lines with correct color
- fix(layout) stop layout after recursion threshold is reached
## v7.8.1 (Plannad at 15.12.2020) ## v7.8.1 (Plannad at 15.12.2020)

View File

@ -27,6 +27,10 @@
*********************/ *********************/
#define LV_OBJX_NAME "lv_cont" #define LV_OBJX_NAME "lv_cont"
#ifndef LV_LAYOUT_MAX_RECURSION
#define LV_LAYOUT_MAX_RECURSION 10
#endif
/********************** /**********************
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
@ -664,6 +668,10 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
return; return;
} }
static int recursion_level = 0;
recursion_level++;
/*Ensure it won't keep recursing forever*/
if(recursion_level <= LV_LAYOUT_MAX_RECURSION) {
lv_area_t tight_area; lv_area_t tight_area;
lv_area_t ori; lv_area_t ori;
lv_obj_t * child_i; lv_obj_t * child_i;
@ -800,6 +808,11 @@ static void lv_cont_refr_autofit(lv_obj_t * cont)
child_i->signal_cb(child_i, LV_SIGNAL_PARENT_SIZE_CHG, &ori); child_i->signal_cb(child_i, LV_SIGNAL_PARENT_SIZE_CHG, &ori);
} }
} }
} else {
LV_LOG_ERROR("LV_LAYOUT_MAX_RECURSION reached! You may have encountered issue #1539.");
}
recursion_level--;
} }
#endif #endif