[vlc-devel] Re: [PATCH] - fix frees w/out NULLs
Pierre d'Herbemont
pdherbemont at free.fr
Thu Jun 7 23:28:17 CEST 2007
On 7 juin 07, at 23:11, Andrew Stone wrote:
> Hi All,
>
> Here is a patch that goes through and sets a lot of pointers to
> NULL after they are freed. Please remember to do this, otherwise
> some nasty bugs can arise. It's much better to crash on a null
> pointer.
>
> Note that I only took care of a few files here, there are still
> thousands more of these to be fixed.
Index: src/misc/objects.c
> - if( p_this->psz_header ) free( p_this->psz_header );
> + if( p_this->psz_header )
> + {
> + free( p_this->psz_header );
> + p_this->psz_header = NULL;
> + }
Seems that you are mixing space/tabs here (more occurence in the rest
of the patch though). Spaces should be used.
Also, I am not sure we really want to do this. For instance in the
above this is absolutely unecessary as we won't reuse the ptr. So I
guess your patch add a lot of junk code.
However you're point is interesting. But rather than implementing
that way you could use a simple macro that redefine free() to set to
NULL the pointer. 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.
Pierre.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070607/99c6575f/attachment.html>
More information about the vlc-devel
mailing list