aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-03-18 18:01:52 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-09 13:53:29 +0200
commit61f87c7207b5d468b540526baa483bb3ee91f00f (patch)
tree07816e54d61fc3a5150e116f846dbcc3cab09a7d /libavformat/movenc.c
parentd4d9c117ebd99123a55025c605c33c8a321876b3 (diff)
downloadffmpeg-61f87c7207b5d468b540526baa483bb3ee91f00f.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>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1028138a5e..1117781a28 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5393,11 +5393,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;
}