Reinhard Tartler <siret...@gmail.com> writes:

> On Wed, Oct 17, 2012 at 11:39 PM, Måns Rullgård <m...@mansr.com> wrote:
>> Reinhard Tartler <siret...@tauware.de> writes:
>>
>>> From: Michael Niedermayer <michae...@gmx.at>
>>>
>>> Fixes Ticket1629
>>>
>>> Signed-off-by: Michael Niedermayer <michae...@gmx.at>
>>> (cherry picked from commit 3d7817048cb387de87600f2152075f78b37b60a6)
>>>
>>> Signed-off-by: Reinhard Tartler <siret...@tauware.de>
>>> ---
>>>  libavcodec/escape124.c |    4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c
>>> index 40224fb..c04af69 100644
>>> --- a/libavcodec/escape124.c
>>> +++ b/libavcodec/escape124.c
>>> @@ -48,7 +48,7 @@ typedef struct Escape124Context {
>>>      CodeBook codebooks[3];
>>>  } Escape124Context;
>>>
>>> -static int can_safely_read(GetBitContext* gb, int bits) {
>>> +static int can_safely_read(GetBitContext* gb, uint64_t bits) {
>>>      return get_bits_left(gb) >= bits;
>>>  }
>>>
>>> @@ -89,7 +89,7 @@ static CodeBook unpack_codebook(GetBitContext* gb, 
>>> unsigned depth,
>>>      unsigned i, j;
>>>      CodeBook cb = { 0 };
>>>
>>> -    if (!can_safely_read(gb, size * 34))
>>> +    if (!can_safely_read(gb, size * 34L))
>>>          return cb;
>
> Would this be a better condition then:
>
> if (size>=UINT_MAX/34 || !can_safely_read(gb, size * 34U))
>   return cb;

size is unsigned so the U suffix isn't needed.

Moreover, I wonder if the can_safely_read() thing is even needed in most
places now that we have the safe bitstream reader.  Certainly some of
them are unnecessary.

-- 
Måns Rullgård
m...@mansr.com
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to