[FFmpeg-devel] [PATCH v2 1/6] avcodec/qsv_h2645: fix memory leak for plugin load
Anton Khirnov
anton at khirnov.net
Mon Feb 1 11:57:24 EET 2021
Quoting Guangxin Xu (2021-01-30 04:19:27)
> Hi Anton, Haihao
> If this is the case, we allocated the string in caller, free and reallocate
> it in callee.
> It's not a good practice.
> 1. It will make the user confused, The original qsvdec_other.c author and I
> are both confused about this.
> https://github.com/FFmpeg/FFmpeg/blob/399c1f923574234e899beef72fe249863bd1722a/libavcodec/qsvdec_other.c#L86
I see no problem with reallocating the string really, as long as av_free
is used it makes no difference. Also note, that all other
AV_OPT_TYPE_STRING options are freed in this manner, so for someone who
understand the AVOption API it is confusing to free just this one
explicitly.
> 2. The av_opt_free may change the design in the future, the new design may
> not use av_freep to free the string
That is very unlikely, as that would be a massive API break. I can think
of no reason to do it.
Also note that extra frees are harmless, other than causing confusion.
--
Anton Khirnov
More information about the ffmpeg-devel
mailing list