[FFmpeg-cvslog] r22077 - trunk/ffmpeg.c

Reimar Döffinger Reimar.Doeffinger
Fri Feb 26 18:54:38 CET 2010


On Fri, Feb 26, 2010 at 03:46:20PM +0100, benoit wrote:
> Author: benoit
> Date: Fri Feb 26 15:46:20 2010
> New Revision: 22077
> 
> Log:
> Prevent overflow of start_time + recording_time.
> Patch by Francesco Cosoleto gmail($name)
> 
> Modified:
>    trunk/ffmpeg.c
> 
> Modified: trunk/ffmpeg.c
> ==============================================================================
> --- trunk/ffmpeg.c	Fri Feb 26 15:32:27 2010	(r22076)
> +++ trunk/ffmpeg.c	Fri Feb 26 15:46:20 2010	(r22077)
> @@ -2305,7 +2305,8 @@ static int av_encode(AVFormatContext **o
>          }
>  
>          /* finish if recording time exhausted */
> -        if (av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {
> +        if (recording_time != INT64_MAX &&
> +            av_compare_ts(pkt.pts, ist->st->time_base, recording_time + start_time, (AVRational){1, 1000000}) >= 0) {

I think the commit message is not particularly good, it can still easily overflow with e.g.
recording_time == INT64_MAX - 1
I think it's more accurate to say that this special-cases a non-specified recording_time to avoid
integer overflows in that case.
To avoid the overflow in general (though the behaviour would theoretically be wrong) the check
should probably be something like
start_time < 0 || recording_time < INT64_MAX - start_time
(not that it should be relevant in practice).



More information about the ffmpeg-cvslog mailing list