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

Benoit Fouet benoit.fouet
Wed Sep 19 09:18:51 CEST 2007


Stefano Sabatini wrote:
> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c	(revision 10526)
> +++ ffmpeg.c	(working copy)
> @@ -2494,21 +2494,38 @@
>  static void opt_recording_time(const char *arg)
>  {
>      recording_time = parse_date(arg, 1);
> +    if (recording_time == INT64_MIN) {
> +        fprintf(stderr, "Invalid duration specification: %s\n", arg);
> +        exit(1);
> +    }
>  }
>  
>  static void opt_start_time(const char *arg)
>  {
>      start_time = parse_date(arg, 1);
> +    if (start_time == INT64_MIN) {
> +        fprintf(stderr, "Invalid duration specification: %s\n", arg);
> +        exit(1);
> +    }
>  }
>  
>  static void opt_rec_timestamp(const char *arg)
>  {
> -    rec_timestamp = parse_date(arg, 0) / 1000000;
> +    int64_t rec_timestamp_us = parse_date(arg, 0);
> +    if (rec_timestamp_us == INT64_MIN) {
> +        fprintf(stderr, "Invalid date specification: %s\n", arg);
> +        exit(1);
> +    }
> +    rec_timestamp = rec_timestamp_us / 1000000;
>  }
>  
>  static void opt_input_ts_offset(const char *arg)
>  {
>      input_ts_offset = parse_date(arg, 1);
> +    if (input_ts_offset == INT64_MIN) {
> +        fprintf(stderr, "Invalid duration specification: %s\n", arg);
> +        exit(1);
> +    }
>  }
>   

you could maybe add a function:
static void foo(int64_t &ts, const char *arg, int duration)
{
    *ts = parse_date(arg, duration);
    if (*ts == INT64_MIN) {
        fprintf(stderr, "....");
        exit(1);
    }
}

and use it in all those places.

apart from that, i would say that the patch looks good, but wait for
Michael's approval, of course...

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




More information about the ffmpeg-devel mailing list