[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input
Diego Biurrun
diego
Tue Sep 18 18:01:25 CEST 2007
On Tue, Sep 18, 2007 at 05:50:37PM +0200, Stefano Sabatini wrote:
>
> New patch attached.
>
> --- 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 occur sanely */
Didn't succeed? What are you trying to say?
> --- 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);
> + }
> --- ffplay.c (revision 10526)
> +++ ffplay.c (working copy)
> @@ -2406,6 +2406,10 @@
> static void opt_seek(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_debug(const char *arg)
Smells like code duplication. No, I don't know a clever way to get
around it offhand.
Diego
More information about the ffmpeg-devel
mailing list