[vlc-devel] Re: [PATCH] - fix frees w/out NULLs

Rémi Denis-Courmont rdenis at simphalempin.com
Fri Jun 8 08:26:06 CEST 2007


On Thu, 7 Jun 2007 23:28:17 +0200, Pierre d'Herbemont <pdherbemont at free.fr>
wrote:
> But rather than implementing
> that way you could use a simple macro that redefine free() to set to
> NULL the pointer.

Such a macro would either:
- not be expansion-safe which is a big NO NO in that case,
- be a static inline that requires a pointer to the pointer which is
probably more overhead that we want.

I'd rather stick to manually setting NULL "when appropriate".

> My only concern is that we sometimes do really need
> to set the pointer to NULL whereas sometimes not.
> Such a patch will hide this subtlety for sure, which is not good.

Same here. There are cases where setting NULL is the right thing
(because further code expects it), some where it helps find bugs
(by crashing VLC instead of doing undefined stuff), some where it is
outright useless because the pointer is not ever used again, and some
where it hides bug (e.g. free(NULL) does nothing so you cannot detect
double-free bugs anymore, with say, valgrind).

It's not B&W...

-- 
Rémi Denis-Courmont
http://www.remlab.net/

-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html



More information about the vlc-devel mailing list