make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL.
authorOzkan Sezer <sezero@users.sourceforge.net>
Thu, 12 Oct 2017 14:28:05 +0300
changeset 1160122fe56a64c6f
parent 11600 03f7e24556ab
child 11602 8dd72342f1f1
make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL.
src/stdlib/SDL_malloc.c
     1.1 --- a/src/stdlib/SDL_malloc.c	Thu Oct 12 08:08:04 2017 -0700
     1.2 +++ b/src/stdlib/SDL_malloc.c	Thu Oct 12 14:28:05 2017 +0300
     1.3 @@ -33,11 +33,17 @@
     1.4  
     1.5  void *SDL_malloc(size_t size)
     1.6  {
     1.7 +    if (!size) {
     1.8 +        return malloc(1);
     1.9 +    }
    1.10      return malloc(size);
    1.11  }
    1.12  
    1.13  void *SDL_calloc(size_t nmemb, size_t size)
    1.14  {
    1.15 +    if (!size || !nmemb) {
    1.16 +        return calloc(1,1);
    1.17 +    }
    1.18      return calloc(nmemb, size);
    1.19  }
    1.20