Merge 'Limit check to avoid crash in flood Fill' form 'master' into sdl2.0

This commit is contained in:
Pere Pujal i Carabantes 2021-11-21 11:36:48 +01:00
commit 6007479b0e

View file

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