Limit check to avoid crash in flood Fill

Reported by Shin-ichi, repaired by Pere.  Thanks!
This commit is contained in:
Bill Kendrick 2021-11-20 20:57:55 -08:00
parent e77c7766cd
commit 81fff34795

View file

@ -443,16 +443,15 @@ void simulate_flood_fill_outside_check(int x, int y, int y_outside)
/* Continue filling upwards from this scanline */
just_queued = 0;
if (y > 0)
{
for (i = narrowFillL; i <= narrowFillR; i++)
{
px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, i, y - 1);
closeness = colors_close(global_canvas, px_colr, global_old_colr);
if (y > 0 &&
(
closeness < COLOR_MATCH_NARROW ||
if (closeness < COLOR_MATCH_NARROW ||
(closeness < COLOR_MATCH_WIDE && y_outside < WIDE_MATCH_THRESHOLD)
)
)
{
if (!just_queued && (global_touched == NULL || !global_touched[((y - 1) * global_canvas->w) + i]))
{
@ -469,21 +468,21 @@ void simulate_flood_fill_outside_check(int x, int y, int y_outside)
just_queued = 0;
}
}
}
/* Continue filling downwards from this scanline */
just_queued = 0;
if (y < global_canvas->h - 1)
{
for (i = narrowFillL; i <= narrowFillR; i++)
{
px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, i, y + 1);
closeness = colors_close(global_canvas, px_colr, global_old_colr);
if (y < global_canvas->h &&
(
closeness < COLOR_MATCH_NARROW ||
if (closeness < COLOR_MATCH_NARROW ||
(closeness < COLOR_MATCH_WIDE && y_outside < WIDE_MATCH_THRESHOLD)
)
)
{
if (!just_queued && (global_touched == NULL || !global_touched[((y + 1) * global_canvas->w) + i]))
{
@ -501,6 +500,7 @@ void simulate_flood_fill_outside_check(int x, int y, int y_outside)
}
}
}
}
void draw_linear_gradient(SDL_Surface * canvas, SDL_Surface * last,