]> git.sesse.net Git - ffmpeg/commitdiff
libavformat/avidec: check memory allocation
authorChris Miceli <chris@miceli.net.au>
Tue, 13 Oct 2020 03:22:25 +0000 (14:22 +1100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 14 Oct 2020 19:11:49 +0000 (21:11 +0200)
Memory allocation for AVIOContext should be checked. In this code,
all error conditions are sent to the "goto error".

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/avidec.c

index 9765e5e7b2c074f80edc95f775ab754293057b1f..33e50e98782f4fc6b6c6defef8f1a9bd0436327e 100644 (file)
@@ -1072,11 +1072,15 @@ static int read_gab2_sub(AVFormatContext *s, AVStream *st, AVPacket *pkt)
         ff_const59 AVInputFormat *sub_demuxer;
         AVRational time_base;
         int size;
+        AVProbeData pd;
+        unsigned int desc_len;
         AVIOContext *pb = avio_alloc_context(pkt->data + 7,
                                              pkt->size - 7,
                                              0, NULL, NULL, NULL, NULL);
-        AVProbeData pd;
-        unsigned int desc_len = avio_rl32(pb);
+        if (!pb)
+            goto error;
+
+        desc_len = avio_rl32(pb);
 
         if (desc_len > pb->buf_end - pb->buf_ptr)
             goto error;