diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-03-18 18:01:52 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-11 21:23:49 +0200 |
commit | c932b82cc9bb57071d8eda9dd5151383963a9559 (patch) | |
tree | 0928fb2840a2ea4eb1ac36b8d8c92a75926bc7d8 | |
parent | 225d542c34e668982c712b0f628f455803f14a55 (diff) | |
download | ffmpeg-c932b82cc9bb57071d8eda9dd5151383963a9559.tar.gz |
avformat/movenc: Avoid loosing cluster array on failure
Fixes: crash
Fixes: check_pkt.mp4
Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5c2ff44f915d6ceeea36a2f99e534562764218dd)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/movenc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 9fbfd9645c..623a8f6b47 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -5173,11 +5173,12 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) if (trk->entry >= trk->cluster_capacity) { unsigned new_capacity = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE); - if (av_reallocp_array(&trk->cluster, new_capacity, - sizeof(*trk->cluster))) { + void *cluster = av_realloc_array(trk->cluster, new_capacity, sizeof(*trk->cluster)); + if (!cluster) { ret = AVERROR(ENOMEM); goto err; } + trk->cluster = cluster; trk->cluster_capacity = new_capacity; } |