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

Reviewed-by: Benoit Fouet <benoit.fouet@free.fr>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/86/head
Michael Niedermayer 10 years ago
parent 3f5095f213
commit 8ba6945487
  1. 2
      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) static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
{ {
void **p = ptr; void **p = ptr;
if (min_size < *size) if (min_size <= *size && *p)
return 0; return 0;
min_size = FFMAX(17 * min_size / 16 + 32, min_size); min_size = FFMAX(17 * min_size / 16 + 32, min_size);
av_free(*p); av_free(*p);

Loading…
Cancel
Save