aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mpegtsenc.c
diff options
context:
space:
mode:
authorAlex Converse <alex.converse@gmail.com>2011-11-28 00:48:53 -0800
committerAlex Converse <alex.converse@gmail.com>2011-11-28 11:22:40 -0800
commitac47e014bbaf5163871a8beb7522015e0bc27615 (patch)
tree4f9b6c59c991d607d756f50d41122622ae00a625 /libavformat/mpegtsenc.c
parenta27805189ba505834c74ec72edc5fddf18f5cfa9 (diff)
downloadffmpeg-ac47e014bbaf5163871a8beb7522015e0bc27615.tar.gz
adtsenc: Check frame size.
Inspired by work from: Michael Niedermayer <michaelni@gmx.at>. Signed-off-by: Alex Converse <alex.converse@gmail.com>
Diffstat (limited to 'libavformat/mpegtsenc.c')
-rw-r--r--libavformat/mpegtsenc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 9f45f13247..f28b719a29 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -971,7 +971,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
return -1;
if ((AV_RB16(pkt->data) & 0xfff0) != 0xfff0) {
ADTSContext *adts = ts_st->adts;
- int new_size;
+ int new_size, err;
if (!adts) {
av_log(s, AV_LOG_ERROR, "aac bitstream not in adts format "
"and extradata missing\n");
@@ -983,7 +983,12 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
data = av_malloc(new_size);
if (!data)
return AVERROR(ENOMEM);
- ff_adts_write_frame_header(adts, data, pkt->size, adts->pce_size);
+ err = ff_adts_write_frame_header(adts, data, pkt->size,
+ adts->pce_size);
+ if (err < 0) {
+ av_free(data);
+ return err;
+ }
if (adts->pce_size) {
memcpy(data+ADTS_HEADER_SIZE, adts->pce_data, adts->pce_size);
adts->pce_size = 0;