@@ -1425,8 +1425,12 @@ clip_line(SDL_Surface *surf, SDL_Rect surf_clip_rect, int *x1, int *y1,
1425
1425
}
1426
1426
1427
1427
static int
1428
- set_at (SDL_Surface * surf , SDL_Rect surf_clip_rect , int x , int y , Uint32 color )
1428
+ set_at (SDL_Surface * surf , SDL_Rect surf_clip_rect , int x , long long y ,
1429
+ Uint32 color )
1429
1430
{
1431
+ // y should be long long so that y * surf->pitch doesn't overflow the int
1432
+ // bounds in the case of very large surfaces and drawing on the edge of
1433
+ // them
1430
1434
Uint8 * pixels = (Uint8 * )surf -> pixels ;
1431
1435
1432
1436
if (x < surf_clip_rect .x || x >= surf_clip_rect .x + surf_clip_rect .w ||
@@ -1459,7 +1463,7 @@ static void
1459
1463
set_and_check_rect (SDL_Surface * surf , SDL_Rect surf_clip_rect , int x , int y ,
1460
1464
Uint32 color , int * drawn_area )
1461
1465
{
1462
- if (set_at (surf , surf_clip_rect , x , y , color )) {
1466
+ if (set_at (surf , surf_clip_rect , x , ( long long ) y , color )) {
1463
1467
add_pixel_to_drawn_list (x , y , drawn_area );
1464
1468
}
1465
1469
}
@@ -1788,7 +1792,7 @@ drawhorzlineclip(SDL_Surface *surf, SDL_Rect surf_clip_rect, Uint32 color,
1788
1792
}
1789
1793
1790
1794
if (x1 == x2 ) {
1791
- set_at (surf , surf_clip_rect , x1 , y1 , color );
1795
+ set_at (surf , surf_clip_rect , x1 , ( long long ) y1 , color );
1792
1796
return ;
1793
1797
}
1794
1798
drawhorzline (surf , color , x1 , y1 , x2 );
0 commit comments