Skip to content
Snippets Groups Projects
Commit 76f7e70a authored by Anton Khirnov's avatar Anton Khirnov
Browse files

h264dec: handle zero-sized NAL units in get_last_needed_nal()


The current code will ignore the init_get_bits() failure and do an
invalid read from the uninitialized GetBitContext.

Found-By: default avatarJan Ruge <jan.s.ruge@gmail.com>
Bug-Id: 952
parent 1f7b4f9a
No related branches found
No related tags found
No related merge requests found
......@@ -478,7 +478,7 @@ static void flush_dpb(AVCodecContext *avctx)
static int get_last_needed_nal(H264Context *h)
{
int nals_needed = 0;
int i;
int i, ret;
for (i = 0; i < h->pkt.nb_nals; i++) {
H2645NAL *nal = &h->pkt.nals[i];
......@@ -496,7 +496,14 @@ static int get_last_needed_nal(H264Context *h)
case H264_NAL_DPA:
case H264_NAL_IDR_SLICE:
case H264_NAL_SLICE:
init_get_bits(&gb, nal->data + 1, (nal->size - 1) * 8);
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(&gb))
nals_needed = i;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment