aboutsummaryrefslogtreecommitdiffstats
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-09-10 16:04:26 +0200
commit3d57bede385f64be6814a249673b8754cddc555f (patch)
tree1c66d22fa4abb562442455438d123d248e4d297a /libavformat
parent97bb7b8ac79f859b5d2fe1224bf199ae6ec6e8ae (diff)
downloadffmpeg-3d57bede385f64be6814a249673b8754cddc555f.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')
-rw-r--r--libavformat/movenc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d0bd1824e1..30c864fd7d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5416,11 +5416,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;
}