You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/hevc/hevcdec: move the slice header buffer overread check up in the function
Abort as soon as we're done reading the slice header instead of running extra checks that assume slice data may follow. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
@ -1160,6 +1160,12 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext
|
|||||||
}
|
}
|
||||||
sh->data_offset = align_get_bits(gb) - gb->buffer;
|
sh->data_offset = align_get_bits(gb) - gb->buffer;
|
||||||
|
|
||||||
|
if (get_bits_left(gb) < 0) {
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"Overread slice header by %d bits\n", -get_bits_left(gb));
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
}
|
||||||
|
|
||||||
// Inferred parameters
|
// Inferred parameters
|
||||||
sh->slice_qp = 26U + pps->pic_init_qp_minus26 + sh->slice_qp_delta;
|
sh->slice_qp = 26U + pps->pic_init_qp_minus26 + sh->slice_qp_delta;
|
||||||
if (sh->slice_qp > 51 ||
|
if (sh->slice_qp > 51 ||
|
||||||
@ -1180,12 +1186,6 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_bits_left(gb) < 0) {
|
|
||||||
av_log(s->avctx, AV_LOG_ERROR,
|
|
||||||
"Overread slice header by %d bits\n", -get_bits_left(gb));
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user