[FFmpeg-devel] [PATCH] Avoid pointless check before calling free

Måns Rullgård mans
Thu Feb 3 02:43:04 CET 2011

Cl?ment B?sch <ubitux at gmail.com> writes:

> Hi,
> We recently tracked down and annihilated most of (all?) the if (p) free(p) in
> MPlayer, and I thought it could be a good idea to do the same with FFmpeg. So
> here is two patches:
> - the first one in order to delete a pointless free made on each av_free call,

You obviously meant "pointless if()" ...

> - the second to remove the few remaining if (p) av_free(p) I was able to find.

Thanks for taking the time to do this.  Both patches queued.

> Note that I didn't touch the av_freep ones since I'm not sure of the real
> benefit.

Did you find similar pointless checks related to av_freep, or what do
you mean?

The purpose of av_freep() is to free the buffer and set the pointer to
NULL as an extra precaution against accessing freed memory and double

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list