History

h264: error out on invalid bitdepth.

Fixes invalid reads while initializing the dequant tables, which uses the bit depth to determine the QP table size.

Ronald S. Bultje committed 14 years ago

Commit 0ce4fe41 parent cc412b71 file · +11 −6Browse files

Unified · Split

libavcodec/h264.c+11−6
@@ -2707,11 +2707,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ · 2706 unmodified lines
27072707 s->avctx->level = h->sps.level_idc;
27082708 s->avctx->refs = h->sps.ref_frame_count;
27092709
2710− if(h == h0 && h->dequant_coeff_pps != pps_id){
2711− h->dequant_coeff_pps = pps_id;
2712− init_dequant_tables(h);
2713− }
2714−
27152710 s->mb_width= h->sps.mb_width;
27162711 s->mb_height= h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
27172712
@@ -2786,7 +2781,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ · 68 unmodified lines
27862781 else
27872782 s->avctx->pix_fmt = PIX_FMT_YUV420P10;
27882783 break;
2789− default:
2784+ case 8:
27902785 if (CHROMA444){
27912786 if (s->avctx->colorspace == AVCOL_SPC_RGB) {
27922787 s->avctx->pix_fmt = PIX_FMT_GBRP;
@@ -2802,6 +2797,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ · 9 unmodified lines
28022797 hwaccel_pixfmt_list_h264_jpeg_420 :
28032798 ff_hwaccel_pixfmt_list_420);
28042799 }
2800+ break;
2801+ default:
2802+ av_log(s->avctx, AV_LOG_ERROR,
2803+ "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
2804+ return AVERROR_INVALIDDATA;
28052805 }
28062806
28072807 s->avctx->hwaccel = ff_find_hwaccel(s->avctx->codec->id, s->avctx->pix_fmt);
@@ -2846,6 +2846,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ · 38 unmodified lines
28462846 }
28472847 }
28482848
2849+ if(h == h0 && h->dequant_coeff_pps != pps_id){
2850+ h->dequant_coeff_pps = pps_id;
2851+ init_dequant_tables(h);
2852+ }
2853+
28492854 h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num);
28502855
28512856 h->mb_mbaff = 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t