]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Fix possible heap overflow caused by av_fast_realloc()
authormichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Tue, 25 Mar 2008 10:15:17 +0000 (10:15 +0000)
committermichael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Tue, 25 Mar 2008 10:15:17 +0000 (10:15 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@12579 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/utils.c

index d6522fe7022e0ce4b0dcb022c48d40158e5db0d7..a264297207cdc116f8cfe00fbe65455812770268 100644 (file)
@@ -66,7 +66,11 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
 
     *size= FFMAX(17*min_size/16 + 32, min_size);
 
-    return av_realloc(ptr, *size);
+    ptr= av_realloc(ptr, *size);
+    if(!ptr) //we could set this to the unmodified min_size but this is safer if the user lost the ptr and uses NULL now
+        *size= 0;
+
+    return ptr;
 }
 
 static unsigned int last_static = 0;