[FFmpeg-devel] [PATCH 6/8] avfilter/show_palette: fix memory leak

Marton Balint cus at passwd.hu
Fri Dec 4 23:29:28 CET 2015


>>>      if ((ret = ff_formats_ref(in , &ctx->inputs[0]->out_formats)) < 0 ||
>>>          (ret = ff_formats_ref(out, &ctx->outputs[0]->in_formats)) < 0)
>>> -        return ret;
>>> +        goto fail;
>>>      return 0;
>>> +fail:
>>
>>> +    av_freep(&in->formats);
>>
>> what if in==NULL?
>>
>>> +    av_freep(&in);
>>
>>> +    av_freep(&out->formats);
>>
>> ditto
>>
>>> +    av_freep(&out);
>>> +    return ret;
>>>  }
>
> Fixed locally with an if(in) and similar checks. Also applies to other
> patches I sent.

Maybe it's just me, but don't we usually use two labels for such cases?

E.g.

fail1:
    av_freep(&in->xxx);
fail2:
    av_freep(&in);
    return ret;

Regards,
Marton


More information about the ffmpeg-devel mailing list