mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-20 22:16:49 +01:00
Fixed potential overflow in surface allocation (thanks Yves!)
This commit is contained in:
parent
312da2623a
commit
d9e1036e0f
@ -80,7 +80,15 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
|
||||
/* Get the pixels */
|
||||
if (surface->w && surface->h) {
|
||||
surface->pixels = SDL_malloc(surface->h * surface->pitch);
|
||||
int size = (surface->h * surface->pitch);
|
||||
if (size < 0 || (size / surface->pitch) != surface->h) {
|
||||
/* Overflow... */
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface->pixels = SDL_malloc(size);
|
||||
if (!surface->pixels) {
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_OutOfMemory();
|
||||
|
Loading…
Reference in New Issue
Block a user