diff options
author | Carl Eugen Hoyos <ceffmpeg@gmail.com> | 2018-01-02 01:58:35 +0100 |
---|---|---|
committer | Carl Eugen Hoyos <ceffmpeg@gmail.com> | 2018-01-04 05:39:18 +0100 |
commit | 695b1d81117d6708a5db2d7115b73ef7c6e1a090 (patch) | |
tree | f9f4f7a9533ea05c0fd10266ccc899e4e572221c /libavutil | |
parent | f141b353e60f1081185927a1e74a9ab46cae8bef (diff) | |
download | ffmpeg-streaming-695b1d81117d6708a5db2d7115b73ef7c6e1a090.zip ffmpeg-streaming-695b1d81117d6708a5db2d7115b73ef7c6e1a090.tar.gz |
lavu/mem: Allow allocations close to max_alloc_size with av_fast_realloc().
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/mem.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libavutil/mem.c b/libavutil/mem.c index 0729e1d..6149755 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -466,7 +466,12 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) if (min_size <= *size) return ptr; - min_size = FFMAX(min_size + min_size / 16 + 32, min_size); + if (min_size > max_alloc_size - 32) { + *size = 0; + return NULL; + } + + min_size = FFMIN(max_alloc_size - 32, FFMAX(min_size + min_size / 16 + 32, min_size)); ptr = av_realloc(ptr, min_size); /* we could set this to the unmodified min_size but this is safer |