aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClément Bœsch <cboesch@gopro.com>2017-01-31 17:17:21 +0100
committerClément Bœsch <cboesch@gopro.com>2017-01-31 17:23:14 +0100
commit4039076dc39a530f29969b6f42083a03215c6aa5 (patch)
treeb023bc040046e298ec2f131214fb84cbc93fb7fe
parent5f633c39cd3ec13ea97e0a7474d452fd5cff8243 (diff)
parent76f7e70aa04fc5dbef5242b11cbf8fe4499f61d4 (diff)
downloadffmpeg-4039076dc39a530f29969b6f42083a03215c6aa5.tar.gz
Merge commit '76f7e70aa04fc5dbef5242b11cbf8fe4499f61d4'
* commit '76f7e70aa04fc5dbef5242b11cbf8fe4499f61d4': h264dec: handle zero-sized NAL units in get_last_needed_nal() See 641dccc2aa5e0bf6b3c06998f9a7f24a5cf725e7 Merged-by: Clément Bœsch <cboesch@gopro.com>
-rw-r--r--libavcodec/h264dec.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 0994b83f81..41c0964392 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -537,8 +537,7 @@ static int get_last_needed_nal(H264Context *h)
{
int nals_needed = 0;
int first_slice = 0;
- int i;
- int ret;
+ int i, ret;
for (i = 0; i < h->pkt.nb_nals; i++) {
H2645NAL *nal = &h->pkt.nals[i];
@@ -556,9 +555,14 @@ static int get_last_needed_nal(H264Context *h)
case H264_NAL_DPA:
case H264_NAL_IDR_SLICE:
case H264_NAL_SLICE:
- ret = init_get_bits8(&gb, nal->data + 1, (nal->size - 1));
- if (ret < 0)
- return ret;
+ ret = init_get_bits8(&gb, nal->data + 1, nal->size - 1);
+ if (ret < 0) {
+ av_log(h->avctx, AV_LOG_ERROR, "Invalid zero-sized VCL NAL unit\n");
+ if (h->avctx->err_recognition & AV_EF_EXPLODE)
+ return ret;
+
+ break;
+ }
if (!get_ue_golomb_long(&gb) || // first_mb_in_slice
!first_slice ||
first_slice != nal->type)