aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-03-18 18:01:52 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-06 14:41:41 +0200
commit3ac8105084fc0580ec536a22b4a5907b61d2c3b0 (patch)
tree2803e02303373cdb4ee9b307fa05939c3e0cca7e
parentd75ae8f6a7c31b19c5d0c1536ef64ccd34feb25b (diff)
downloadffmpeg-3ac8105084fc0580ec536a22b4a5907b61d2c3b0.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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c34d86522a..286418915f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5605,11 +5605,12 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
if (trk->entry >= trk->cluster_capacity) {
unsigned new_capacity = 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;
}