Diego Biurrun <[email protected]> writes: > User-provided data should never trigger an assert; also fix an instance of > get_bits where get_bits_long should have been used. This fixes the warning: > libavcodec/vaapi_mpeg2.c:112:14: warning: variable 'start_code' set but not > used > --- > libavcodec/vaapi_mpeg2.c | 5 +++-- > 1 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c > index 561f4bf..5da873e 100644 > --- a/libavcodec/vaapi_mpeg2.c > +++ b/libavcodec/vaapi_mpeg2.c > @@ -115,8 +115,9 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext > *avctx, const uint8_t *buffer > > /* Determine macroblock_offset */ > init_get_bits(&gb, buffer, 8 * size); > - start_code = get_bits(&gb, 32); > - assert((start_code & 0xffffff00) == 0x00000100); > + start_code = get_bits_long(&gb, 32); > + if (!((start_code & 0xffffff00) == 0x00000100)) > + return AVERROR_INVALIDDATA; > quantiser_scale_code = get_bits(&gb, 5); > intra_slice_flag = get_bits1(&gb); > if (intra_slice_flag) { > --
if (foo != bar) is much nicer than if (!(foo == bar)), don't you think? BTW, if (start_code >> 8 != 1) is another way of writing this. -- Måns Rullgård [email protected] _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
