[FFmpeg-devel] [PATCH 18/40] avcodec/alacenc: Don't free unnecessarily

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Sep 14 19:43:46 EEST 2020


Paul B Mahol:
> On Mon, Sep 14, 2020 at 07:27:25AM +0200, Andreas Rheinhardt wrote:
>> The init function of the ALAC encoder calls its own close function
>> if a call to ff_lpc_init() fails; yet nothing has been allocated before
>> that point (except extradata which is freed generically) and ff_lpc_init()
>> can be expected to clean up after itself on error (the documentation does
>> not say anything to the contrary and the current implementation can only
>> fail if the only allocation fails, so there is nothing to clean up on
>> error anyway), so this is unnecessary.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
>> ---
>>  libavcodec/alacenc.c | 20 ++++++--------------
>>  1 file changed, 6 insertions(+), 14 deletions(-)
>>
> 
> what about adding cleanup flag so if new stuff is added(unlikely) new bugs
> wont pop up?
> 

That is possible, but as you said yourself: It is unlikely that new
stuff will be added. Furthermore, I think that whoever adds new stuff
would be responsible to make sure that it is free of leaks.

- Andreas


More information about the ffmpeg-devel mailing list