OSDN Git Service

avcodec/utils: Fix off by 1 error causing unneeded allocation in ff_fast_malloc()
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 29 Sep 2014 03:41:54 +0000 (05:41 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 29 Sep 2014 10:56:45 +0000 (12:56 +0200)
Reviewed-by: Benoit Fouet <benoit.fouet@free.fr>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/utils.c

index b27f918..9eb2b5b 100644 (file)
@@ -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);