mpeg4audio: check the init_get_bits() return value
authorAnton Khirnov <anton@khirnov.net>
Thu, 1 Jan 2015 16:56:56 +0000 (17:56 +0100)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 12 Jan 2015 21:21:54 +0000 (22:21 +0100)
Fixes possible invalid reads.

CC:libav-stable@libav.org
(cherry picked from commit 7e4e010b80e76862e83afbd41c25d50e72f0b44c)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/mpeg4audio.c

index 0fb9b96c801e343b785a330a99b16c9457d99b27..2363cb637d4137c0c90a54b42b2d48035202cdd6 100644 (file)
@@ -80,9 +80,11 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
                                  int bit_size, int sync_extension)
 {
     GetBitContext gb;
-    int specific_config_bitindex;
+    int specific_config_bitindex, ret;
 
-    init_get_bits(&gb, buf, bit_size);
+    ret = init_get_bits(&gb, buf, bit_size);
+    if (ret < 0)
+        return ret;
     c->object_type = get_object_type(&gb);
     c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
     c->chan_config = get_bits(&gb, 4);