summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-03-18 18:01:52 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-03-26 16:00:14 +0100
commit5c2ff44f915d6ceeea36a2f99e534562764218dd (patch)
treebfdd95c7d2b26a41fbbc07deb2aef999bd457888 /libavformat
parentd0a937caeceb9f1fcf61bcd986dab5e6283a67e2 (diff)
downloadffmpeg-5c2ff44f915d6ceeea36a2f99e534562764218dd.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>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/movenc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6790fe6c45..bade57dcea 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5746,11 +5746,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;
}