[FFmpeg-devel] [PATCH 1/3] avfilter/avfilter: Fix leaks upon filter creation error
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Aug 11 22:19:59 EEST 2021
Nicolas George:
> Andreas Rheinhardt (12021-08-11):
>> Both the name as well as the options need to be freed.
>> (Right now there is no option for the AVFilterContext itself that could
>> leak, but some filters have options (e.g. of type AV_OPT_TYPE_STRING)
>> that can leak.)
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
>
> LGTM.
>
I have now found an issue with this patch: If preinit fails (no current
preinit seems to be able to fail), then av_opt_free() will be called
before the AVClass has been set on the private context (presuming the
filter to have a private class).
Furthermore, there are more problems here: The documentation states that
uninit will be called on preinit failure. This is just not true.
Finally, nb_(in|out)puts is set before the structures necessary for this
have been allocated and if uninit is called (due to preinit success),
then freeing the pads names might crash; seems like none of the filters
that currently have a preinit are affected by this (only the xmedian
filter has dynamic inputs, but it has no static inputs, so it is safe).
I will therefore send an updated patch; I will also send a patch to free
the name of pads generically based upon a internal flag.
- Andreas
More information about the ffmpeg-devel
mailing list