[FFmpeg-cvslog] avcodec/utils: Fix off by 1 error causing unneeded allocation in ff_fast_malloc()

Michael Niedermayer git at videolan.org
Mon Sep 29 13:03:57 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Sep 29 05:41:54 2014 +0200| [8ba694548782c1821ab119c18fe02360a81c6768] | committer: Michael Niedermayer

avcodec/utils: Fix off by 1 error causing unneeded allocation in ff_fast_malloc()

Reviewed-by: Benoit Fouet <benoit.fouet at free.fr>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavcodec/utils.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b27f918..9eb2b5b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -122,7 +122,7 @@ static void *avformat_mutex;
 static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
 {
     void **p = ptr;
-    if (min_size < *size)
+    if (min_size <= *size && *p)
         return 0;
     min_size = FFMAX(17 * min_size / 16 + 32, min_size);
     av_free(*p);



More information about the ffmpeg-cvslog mailing list