changeset 6532:8aafb712389e libavcodec

Fix possible heap overflow caused by av_fast_realloc()
author michael
date Tue, 25 Mar 2008 10:15:17 +0000
parents 7781f4e99d37
children b4c000318ed4
files utils.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/utils.c	Mon Mar 24 22:25:30 2008 +0000
+++ b/utils.c	Tue Mar 25 10:15:17 2008 +0000
@@ -66,7 +66,11 @@
 
     *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;