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

James Almer jamrial at gmail.com
Sun Mar 12 19:32:22 EET 2017


On 3/12/2017 2:10 PM, Michael Niedermayer wrote:
> 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

Pushed



More information about the ffmpeg-devel mailing list