[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input

Benoit Fouet benoit.fouet
Wed Sep 19 14:38:18 CEST 2007


Stefano Sabatini wrote:
> On date Wednesday 2007-09-19 12:28:08 +0200, Michael Niedermayer encoded:
>   
>> Hi
>>
>> On Wed, Sep 19, 2007 at 11:27:39AM +0200, Stefano Sabatini wrote:
>>     
> [...]
>   
>>> Index: libavformat/utils.c
>>> ===================================================================
>>> --- libavformat/utils.c	(revision 10526)
>>> +++ libavformat/utils.c	(working copy)
>>> @@ -2621,17 +2621,19 @@
>>>          if (!q) {
>>>              /* parse datestr as S+ */
>>>              dt.tm_sec = strtol(p, (char **)&q, 10);
>>> +            if (q == p) {
>>> +                /* set q to NULL to signal that the parsing didn't succeed */
>>> +                q = NULL;
>>> +            } else {
>>>              dt.tm_min = 0;
>>>              dt.tm_hour = 0;
>>> +            }
>>>          }
>>>      }
>>>       
>> instead of the if/else blah a simple
>> if(q == p)
>>     return INT64_MIN;
>>
>> seems to be simpler
>>     
>
> Fixed.
>   
>   
>> [...]
>>     
>>> +static void parse_time_or_die(int64_t *us, const char *timestr, int is_duration)
>>> +{
>>> +    *us = parse_date(timestr, is_duration);
>>> +    if (*us == INT64_MIN) {
>>> +        fprintf(stderr, "Invalid %s specification: %s\n",
>>> +                is_duration ? "duration" : "date", timestr);
>>> +        exit(1);
>>> +    }
>>> +}
>>>       
>> return us; would be cleaner IMHO
>>     
>
> Fixed.
>  
>   
>> and iam fine with the patch except these
>>     
> [...]
>
> Thanks all for your reviews, hopefully this will be the last one.
>
>   

Applied

-- 
Ben
Purple Labs S.A.
www.purplelabs.com




More information about the ffmpeg-devel mailing list