summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2008-03-25 10:15:17 +0000
committerMichael Niedermayer <michaelni@gmx.at>2008-03-25 10:15:17 +0000
commit978805b2c518aae480d26e4b44beede300c9a862 (patch)
tree0f1c7e76d34d8ec1deefd7ad0fcbe254fb0ad35b /libavcodec/utils.c
parentcb6b4c98d2f8907f3ef43fbbac7d36de1c0949e2 (diff)
Fix possible heap overflow caused by av_fast_realloc()
Originally committed as revision 12579 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index d6522fe702..a264297207 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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;