Only add 1 byte to av_malloc(0) when it actually returned NULL
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 7 May 2011 13:28:39 +0000 (15:28 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 7 May 2011 14:21:54 +0000 (16:21 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavutil/mem.c

index 83e8c35..42beb50 100644 (file)
@@ -71,8 +71,6 @@ void *av_malloc(size_t size)
     /* let's disallow possible ambiguous cases */
     if(size > (INT_MAX-32) )
         return NULL;
-    else if(!size)
-        size= 1;
 
 #if CONFIG_MEMALIGN_HACK
     ptr = malloc(size+32);
@@ -113,6 +111,8 @@ void *av_malloc(size_t size)
 #else
     ptr = malloc(size);
 #endif
+    if(!ptr && !size)
+        ptr= av_malloc(1);
     return ptr;
 }