mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-18 10:48:28 +00:00
Use a reasonable upper bound on the number of pixels we'll try to draw when traversing a line
Fixes https://github.com/libsdl-org/SDL/issues/6116
This commit is contained in:
parent
d6fdb842b0
commit
2a83093b36
1 changed files with 5 additions and 0 deletions
|
@ -2718,6 +2718,7 @@ int SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y
|
|||
|
||||
static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, int y2, SDL_bool draw_last)
|
||||
{
|
||||
const int MAX_PIXELS = SDL_max(renderer->view->pixel_w, renderer->view->pixel_h) * 4;
|
||||
int i, deltax, deltay, numpixels;
|
||||
int d, dinc1, dinc2;
|
||||
int x, xinc1, xinc2;
|
||||
|
@ -2765,6 +2766,10 @@ static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, i
|
|||
--numpixels;
|
||||
}
|
||||
|
||||
if (numpixels > MAX_PIXELS) {
|
||||
return SDL_SetError("Line too long (tried to draw %d pixels, max %d)", numpixels, MAX_PIXELS);
|
||||
}
|
||||
|
||||
points = SDL_small_alloc(SDL_FPoint, numpixels, &isstack);
|
||||
if (points == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue