diff mbox series

[FFmpeg-devel,3/4] avformat/movenc: Avoid loosing cluster array on failure

Message ID 20210318204958.21176-3-michael@niedermayer.cc
State Accepted
Commit 5c2ff44f915d6ceeea36a2f99e534562764218dd
Headers show
Series [FFmpeg-devel,1/4] avformat/avidec: Check for dv streams before using priv_data in parse ##dc/##wb
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer March 18, 2021, 8:49 p.m. UTC
Fixes: crash
Fixes: check_pkt.mp4

Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/movenc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer March 25, 2021, 5:13 p.m. UTC | #1
On Thu, Mar 18, 2021 at 09:49:57PM +0100, Michael Niedermayer wrote:
> Fixes: crash
> Fixes: check_pkt.mp4
> 
> Found-by: Rafael Dutra <rafael.dutra@cispa.de>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/movenc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

will apply

[...]
diff mbox series

Patch

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;
     }