aboutsummaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorJustin Ruggles2014-06-22 13:19:36 -0400
committerJustin Ruggles2014-06-22 20:31:58 -0400
commitf2f2e7627f0c878d13275af5d166ec5932665e28 (patch)
tree941b6688d11ec10778656d36d44d8aee6b9a9854 /libavformat
parent44127546b0a81dc9dd6190739a62d48f0044c6f3 (diff)
Check mp3 header before calling avpriv_mpegaudio_decode_header().
As indicated in the function documentation, the header MUST be checked prior to calling it because no consistency check is done there. CC:libav-stable@libav.org
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mp3enc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 932625864f..476d7f71cb 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -252,13 +252,16 @@ static int mp3_write_audio_packet(AVFormatContext *s, AVPacket *pkt)
if (mp3->xing_offset && pkt->size >= 4) {
MPADecodeHeader c;
-
- avpriv_mpegaudio_decode_header(&c, AV_RB32(pkt->data));
-
- if (!mp3->initial_bitrate)
- mp3->initial_bitrate = c.bit_rate;
- if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
- mp3->has_variable_bitrate = 1;
+ uint32_t h;
+
+ h = AV_RB32(pkt->data);
+ if (ff_mpa_check_header(h) == 0) {
+ avpriv_mpegaudio_decode_header(&c, h);
+ if (!mp3->initial_bitrate)
+ mp3->initial_bitrate = c.bit_rate;
+ if ((c.bit_rate == 0) || (mp3->initial_bitrate != c.bit_rate))
+ mp3->has_variable_bitrate = 1;
+ }
mp3_xing_add_frame(mp3, pkt);
}