[FFmpeg-devel] [PATCH] test/api-seek: clean up properly on failure

Michael Niedermayer michael at niedermayer.cc
Sun Mar 12 19:10:24 EET 2017


On Sun, Mar 12, 2017 at 10:51:27AM -0300, James Almer wrote:
> Also propagate better error values.
> 
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> To be applied before the realloc memleak fix.
> 
>  tests/api/api-seek-test.c | 31 +++++++++++++++++++------------
>  1 file changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/api/api-seek-test.c b/tests/api/api-seek-test.c
> index 6ef3b91933..b33a5dd158 100644
> --- a/tests/api/api-seek-test.c
> +++ b/tests/api/api-seek-test.c
> @@ -197,19 +197,22 @@ static int seek_test(const char *input_filename, const char *start, const char *
>      result = avformat_find_stream_info(fmt_ctx, NULL);
>      if (result < 0) {
>          av_log(NULL, AV_LOG_ERROR, "Can't get stream info\n");
> -        return result;
> +        goto end;
>      }
>  
>      start_ts = read_seek_range(start);
>      end_ts = read_seek_range(end);
> -    if ((start_ts < 0) || (end_ts < 0))
> -        return -1;
> +    if ((start_ts < 0) || (end_ts < 0)) {
> +        result = -1;
> +        goto end;
> +    }
>  
>      //TODO: add ability to work with audio format
>      video_stream = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
>      if (video_stream < 0) {
>        av_log(NULL, AV_LOG_ERROR, "Can't find video stream in input file\n");
> -      return -1;
> +      result = video_stream;
> +      goto end;
>      }
>  
>      origin_par = fmt_ctx->streams[video_stream]->codecpar;

> @@ -217,52 +220,56 @@ static int seek_test(const char *input_filename, const char *start, const char *
>      codec = avcodec_find_decoder(origin_par->codec_id);
>      if (!codec) {
>          av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n");
> -        return -1;
> +      result = AVERROR_DECODER_NOT_FOUND;
> +      goto end;
>      }

The indention depth looks odd here

should be fine otherwise assuming result is always set appropriately

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170312/d078ca7e/attachment.sig>


More information about the ffmpeg-devel mailing list