avcodec/ac3_parser: Check init_get_bits8() for failure
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 27 Jun 2018 14:59:13 +0000 (16:59 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 28 Jun 2018 19:35:01 +0000 (21:35 +0200)
Fixes: null pointer dereference
Fixes: ffmpeg_crash_6.avi

Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan Caciulescu with AFLSmart
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/ac3_parser.c

index f4618bf..1e203ae 100644 (file)
@@ -162,7 +162,9 @@ int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf,
         return AVERROR(ENOMEM);
     hdr = *phdr;
 
-    init_get_bits8(&gb, buf, size);
+    err = init_get_bits8(&gb, buf, size);
+    if (err < 0)
+        return AVERROR_INVALIDDATA;
     err = ff_ac3_parse_header(&gb, hdr);
     if (err < 0)
         return AVERROR_INVALIDDATA;