From c64c0ef805044177b5bab84e1f7c07da3bf35693 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 15 Apr 2010 21:27:32 -0700 Subject: [PATCH] Fixed bug 984 SDL_CreateTexture allows the creation of textures of size 0, which can lead to div by 0 errors --- src/video/SDL_video.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 2f7d37361..8ac0d1d4c 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1649,6 +1649,10 @@ SDL_CreateTexture(Uint32 format, int access, int w, int h) SDL_Unsupported(); return 0; } + if (w <= 0 || h <= 0) { + SDL_SetError("Texture dimensions can't be 0"); + return 0; + } texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); if (!texture) { SDL_OutOfMemory();