mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-09 11:26:29 +00:00
Prevent potential overflow in rectangle functions
We're limiting the functions to rects with positions and sizes < 1 billion for speed, which is totally fine for most SDL use cases. If you need rectangles larger than that, you can roll your own functions that use 64-bit intermediate values and do proper overflow handling of output values. Fixes https://github.com/libsdl-org/SDL/issues/8879
This commit is contained in:
@@ -91,6 +91,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height,
|
||||
#define BIGSCALARTYPE Sint64
|
||||
#define COMPUTEOUTCODE ComputeOutCode
|
||||
#define ENCLOSEPOINTS_EPSILON 1
|
||||
#define SDL_RECT_CAN_OVERFLOW SDL_RectCanOverflow
|
||||
#define SDL_HASINTERSECTION SDL_HasRectIntersection
|
||||
#define SDL_INTERSECTRECT SDL_GetRectIntersection
|
||||
#define SDL_RECTEMPTY SDL_RectEmpty
|
||||
@@ -105,6 +106,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height,
|
||||
#define BIGSCALARTYPE double
|
||||
#define COMPUTEOUTCODE ComputeOutCodeFloat
|
||||
#define ENCLOSEPOINTS_EPSILON 0.0f
|
||||
#define SDL_RECT_CAN_OVERFLOW SDL_RectCanOverflowFloat
|
||||
#define SDL_HASINTERSECTION SDL_HasRectIntersectionFloat
|
||||
#define SDL_INTERSECTRECT SDL_GetRectIntersectionFloat
|
||||
#define SDL_RECTEMPTY SDL_RectEmptyFloat
|
||||
|
Reference in New Issue
Block a user