aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-04 06:17:49 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-04 06:23:46 +0100
commite2781db62a406114519d55c31dd534db6d60dd0d (patch)
tree177a15668587407f6601758a21ef6fe84c49cf6b /libavcodec
parent9ac7d8f85d71f50d01d97f33cf0cc9f7707d62a3 (diff)
parent44079902c49e526f464bb4eb855665e1af867e91 (diff)
downloadffmpeg-e2781db62a406114519d55c31dd534db6d60dd0d.tar.gz
Merge commit '44079902c49e526f464bb4eb855665e1af867e91' into release/1.1
* commit '44079902c49e526f464bb4eb855665e1af867e91': mov: Free intermediate arrays in the normal cleanup function segafilm: fix leaks if reading the header fails h264_cavlc: check the size of the intra PCM data. h263: Check init_get_bits return value cavsdec: check ff_get_buffer() return value Conflicts: libavcodec/cavsdec.c libavcodec/h263dec.c libavformat/mov.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/cavsdec.c3
-rw-r--r--libavcodec/h263dec.c26
-rw-r--r--libavcodec/h264_cavlc.c4
3 files changed, 22 insertions, 11 deletions
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index 6a783f70f3..14a8e9cfbd 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -979,7 +979,8 @@ static int decode_pic(AVSContext *h)
if (h->cur.f->data[0])
h->avctx->release_buffer(h->avctx, h->cur.f);
- if ((ret = ff_get_buffer(h->avctx, h->cur.f)) < 0)
+ ret = ff_get_buffer(h->avctx, h->cur.f);
+ if (ret < 0)
return ret;
if (!h->edge_emu_buffer) {
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 24df411410..a0cb82c624 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -392,7 +392,6 @@ uint64_t time= rdtsc();
return buf_size;
}
-
retry:
if(s->divx_packed && s->bitstream_buffer_size){
int i;
@@ -407,16 +406,20 @@ retry:
}
}
- if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 5.01+/xvid frame reorder
- init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
- }else
- init_get_bits(&s->gb, buf, buf_size*8);
+ if (s->bitstream_buffer_size && (s->divx_packed || buf_size < 20)) // divx 5.01+/xvid frame reorder
+ ret = init_get_bits8(&s->gb, s->bitstream_buffer,
+ s->bitstream_buffer_size);
+ else
+ ret = init_get_bits8(&s->gb, buf, buf_size);
+
s->bitstream_buffer_size=0;
+ if (ret < 0)
+ return ret;
- if (!s->context_initialized) {
- if ((ret = ff_MPV_common_init(s)) < 0) //we need the idct permutaton for reading a custom matrix
+ if (!s->context_initialized)
+ // we need the idct permutaton for reading a custom matrix
+ if ((ret = ff_MPV_common_init(s)) < 0)
return ret;
- }
/* We need to set current_picture_ptr before reading the header,
* otherwise we cannot store anyting in there */
@@ -436,8 +439,11 @@ retry:
if(s->avctx->extradata_size && s->picture_number==0){
GetBitContext gb;
- init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
- ret = ff_mpeg4_decode_picture_header(s, &gb);
+ ret = init_get_bits8(&gb, s->avctx->extradata,
+ s->avctx->extradata_size);
+ if (ret < 0)
+ return ret;
+ ff_mpeg4_decode_picture_header(s, &gb);
}
ret = ff_mpeg4_decode_picture_header(s, &s->gb);
} else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 7cbc553cc3..eb3869ff39 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -771,6 +771,10 @@ decode_intra_mb:
// We assume these blocks are very rare so we do not optimize it.
align_get_bits(&s->gb);
+ if (get_bits_left(&s->gb) < mb_size) {
+ av_log(s->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n");
+ return AVERROR_INVALIDDATA;
+ }
// The pixels are stored in the same order as levels in h->mb array.
for(x=0; x < mb_size; x++){