[FFmpeg-devel] [PATCH 1/2] avformat/utils: avoid unsigned integer overflows

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat Feb 15 20:06:00 EET 2020


Marton Balint:
> 
> 
> On Sat, 15 Feb 2020, Nicolas George wrote:
> 
>> Marton Balint (12020-02-15):
>>>> +    if (s->nb_streams)
>>>>     for (i = s->nb_streams - 1; i >= 0; i--)
>>> Maybe rewrite the loop instead?
>>>       for (i = s->nb_streams; i-- > 0;)
>>
>> Or
>>
>>    for (i = s->nb_streams - 1; i < s->nb_streams; i--)
> 
> Or simply change the loops to normal ascending order? I don't see why
> these are descending loops in the first place.
> 
Yeah. This sound like the best idea. One just has to call
free_stream() instead of ff_free_stream() for this to work.

- Andreas


More information about the ffmpeg-devel mailing list