[FFmpeg-devel] [PATCH 2/3] ffmdec: cast state to unsigned for left shift

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sat Jan 2 17:12:13 CET 2016


On 02.01.2016 16:56, Nicolas George wrote:
> Le tridi 13 nivôse, an CCXXIV, Andreas Cadhalpun a écrit :
>> This fixes ubsan runtime error: left shift by 8 places cannot be
>> represented in type 'int'
>>
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
>> ---
>>  libavformat/ffmdec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
>> index 7b2d0d7..3162354 100644
>> --- a/libavformat/ffmdec.c
>> +++ b/libavformat/ffmdec.c
>> @@ -76,7 +76,7 @@ static int ffm_resync(AVFormatContext *s, int state)
>>              av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
>>              return -1;
>>          }
>> -        state = (state << 8) | avio_r8(s->pb);
>> +        state = ((unsigned)state << 8) | avio_r8(s->pb);
>>      }
>>      return 0;
>>  }
> 
> IMHO, it would be more correct to make state uint32_t (and id at the call
> site possibly too).

That alternative is fine for me, too. Patch attached.

Happy new year,
Andreas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ffmdec-change-type-of-state-and-id-to-unsigned.patch
Type: text/x-diff
Size: 1246 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160102/344bf1bc/attachment.patch>


More information about the ffmpeg-devel mailing list