fix(draw): resolve infinite loop and out-of-bounds access in circular mask cache calculation (#9864)

This commit is contained in:
Kreedb
2026-03-21 13:10:56 +08:00
committed by GitHub
parent fca39997f5
commit f9c059715d
2 changed files with 28 additions and 1 deletions

View File

@@ -1209,7 +1209,7 @@ static void circ_calc_aa4(lv_draw_sw_mask_radius_circle_dsc_t * c, int32_t radiu
while(i < cir_size) {
c->opa_start_on_y[y] = i;
c->x_start_on_y[y] = cir_x[i];
for(; i < (int32_t)cir_size && cir_y[i] == y; i++) {
for(; i < (int32_t)cir_size && cir_y[i] <= y; i++) {
c->x_start_on_y[y] = LV_MIN(c->x_start_on_y[y], cir_x[i]);
}
y++;

View File

@@ -0,0 +1,27 @@
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "unity/unity.h"
void setUp(void)
{
/* Function run before every test */
}
void tearDown(void)
{
/* Function run after every test */
lv_obj_clean(lv_screen_active());
}
void test_radius_mask_overflow(void)
{
int width = 1280;
int heigh = 1280;
lv_obj_t * obj = lv_obj_create(lv_screen_active());
lv_obj_set_size(obj, width * 2, heigh * 2);
lv_obj_set_style_radius(obj, heigh, LV_PART_MAIN);
lv_timer_handler();
}
#endif