[FFmpeg-devel] [PATCH] vf_hwupload: Add missing return value check

Jun Zhao mypopydev at gmail.com
Fri Mar 3 02:00:47 EET 2017



On 2017/3/1 5:44, Mark Thompson wrote:
> On 27/02/17 02:23, Jun Zhao wrote:
>> From e60a958c78ba084e0745acebec5125394387c5b1 Mon Sep 17 00:00:00 2001
>> From: Jun Zhao <jun.zhao at intel.com>
>> Date: Mon, 27 Feb 2017 10:08:36 +0800
>> Subject: [PATCH] vf_hwupload: Add missing return value checks
>>
>> Add missing return value checks to fix the build warning.
>>
>> Signed-off-by: Jun Zhao <jun.zhao at intel.com>
>> ---
>>  libavfilter/vf_hwupload.c | 10 ++++++----
>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavfilter/vf_hwupload.c b/libavfilter/vf_hwupload.c
>> index 08af2dd..ce39307 100644
>> --- a/libavfilter/vf_hwupload.c
>> +++ b/libavfilter/vf_hwupload.c
>> @@ -81,10 +81,12 @@ static int hwupload_query_formats(AVFilterContext *avctx)
>>          }
>>      }
>>  
>> -    ff_formats_ref(input_formats, &avctx->inputs[0]->out_formats);
>> -
>> -    ff_formats_ref(ff_make_format_list(output_pix_fmts),
>> -                   &avctx->outputs[0]->in_formats);
>> +    if ((err = ff_formats_ref(input_formats, &avctx->inputs[0]->out_formats)) < 0 ||
>> +        (err = ff_formats_ref(ff_make_format_list(output_pix_fmts),
>> +                              &avctx->outputs[0]->in_formats)) < 0) {
>> +        ff_formats_unref(&input_formats);
> 
> This line doesn't do anything.
> 
>> +        goto fail;
>> +    }
>>  
>>      av_hwframe_constraints_free(&constraints);
>>      return 0;
>> -- 
>> 2.9.3
>>
> 
> Are you trying to fix any possible leaks or just to suppress the warning?  If the latter, sure.  If the former, please be aware if you aren't already that the format functions are more subtle that they may appear to be - in particular, note that ff_make_format_list() creates a format list with zero references, and therefore calling unref on such a list does nothing.  (And yes, the use of ff_formats_unref() in the loop above is also wrong, you may want to fix that as well.)
> _

I just want to suppress the warning and didn't aware of calling unref is wrong, will submit V2 patch for this. Thanks.
______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 


More information about the ffmpeg-devel mailing list