Fixed bug 984
authorSam Lantinga <slouken@libsdl.org>
Thu, 15 Apr 2010 21:27:32 -0700
changeset 44339fa97c6b0014
parent 4432 77ebcd41b577
child 4434 5c64052fb476
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
     1.1 --- a/src/video/SDL_video.c	Tue Apr 13 22:01:14 2010 -0700
     1.2 +++ b/src/video/SDL_video.c	Thu Apr 15 21:27:32 2010 -0700
     1.3 @@ -1649,6 +1649,10 @@
     1.4          SDL_Unsupported();
     1.5          return 0;
     1.6      }
     1.7 +    if (w <= 0 || h <= 0) {
     1.8 +        SDL_SetError("Texture dimensions can't be 0");
     1.9 +        return 0;
    1.10 +    }
    1.11      texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
    1.12      if (!texture) {
    1.13          SDL_OutOfMemory();