| 6 |
| 7 | Fixes: out of array read |
| 8 | Fixes: undefined shift |
| 9 | Fixes: 3JrnwpkctVpF |
| 10 | Fixes: hevc_layer_idx_oob.hevc |
| 11 | Fixes: poc.hevc |
| 12 | Replicated through UnModified FFmpeg |
| 13 | Replicated through API |
| 14 | Regression since: 02a9435cb0 |
| 15 | Found-by: Glops Elemiu |
| 16 | Found-by: Kasif Dekel |
| 17 | --- |
| 18 | libavcodec/hevc/hevcdec.c | 8 ++++++-- |
| 19 | 1 file changed, 6 insertions(+), 2 deletions(-) |
| 20 |
| 21 | diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c |
| 22 | index b6234a6c34..9bbe6fe5a5 100644 |
| 23 | --- a/libavcodec/hevc/hevcdec.c |
| 24 | +++ b/libavcodec/hevc/hevcdec.c |
| 25 | @@ -793,8 +793,8 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext |
| 26 | const HEVCPPS *pps; |
| 27 | const HEVCSPS *sps; |
| 28 | const HEVCVPS *vps; |
| 29 | - unsigned pps_id, layer_idx; |
| 30 | - int i, ret; |
| 31 | + unsigned pps_id; |
| 32 | + int i, ret, layer_idx; |
| 33 |
| 34 | // Coded parameters |
| 35 | sh->first_slice_in_pic_flag = get_bits1(gb); |
| 36 | @@ -818,6 +818,10 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext |
| 37 | sps = pps->sps; |
| 38 | vps = sps->vps; |
| 39 | layer_idx = vps->layer_idx[s->nuh_layer_id]; |
| 40 | + if (layer_idx < 0) { |
| 41 | + av_log(s->avctx, AV_LOG_ERROR, "Layer %d is not in the VPS\n", s->nuh_layer_id); |
| 42 | + return AVERROR_INVALIDDATA; |
| 43 | + } |
| 44 |
| 45 | if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) |
| 46 | sh->no_output_of_prior_pics_flag = 1; |
| 47 | -- |
| 48 | 2.55.0 |
| 49 |
| 50 |