[FFmpeg-cvslog] Only add 1 byte to av_malloc(0) when it actually returned NULL

Michael Niedermayer git at videolan.org
Sat May 7 16:23:57 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat May  7 15:28:39 2011 +0200| [c8981edd902e40185b80ddb77a229104deb7c7e1] | committer: Michael Niedermayer

Only add 1 byte to av_malloc(0) when it actually returned NULL
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8981edd902e40185b80ddb77a229104deb7c7e1
---

 libavutil/mem.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index 83e8c35..42beb50 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -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;
 }
 



More information about the ffmpeg-cvslog mailing list