From bef0fec121b4dcc74b2d0b6d036f020c571cbcca Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Thu, 12 Oct 2017 14:28:05 +0300 Subject: [PATCH] make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL. --- src/stdlib/SDL_malloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index db3b107857da7..de7f13a9456b2 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -33,11 +33,17 @@ void *SDL_malloc(size_t size) { + if (!size) { + return malloc(1); + } return malloc(size); } void *SDL_calloc(size_t nmemb, size_t size) { + if (!size || !nmemb) { + return calloc(1,1); + } return calloc(nmemb, size); }