Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!uunet!ontek!john From: john@ontek.UUCP (John Stanley) Newsgroups: comp.lang.c Subject: Re: effect of free() Summary: NULL it all out... Message-ID: <549@ontek.UUCP> Date: 8 Sep 89 23:07:10 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU> <248@seti.inria.fr> Organization: Ontek Corporation, Laguna Hills, CA Lines: 13 In article <248@seti.inria.fr>, jourdan@seti.inria.fr (jourdan martin joseph) writes: > The morale of the whole story is: DO NOT DO ANYTHING WITH A FREED > POINTER. To make things safer, each time I free a pointer variable, > the next statement is to copy some valid pointer value (usually NULL) > into it. Of course, that does not solve the aliasing problem which > was the basis of the whole discussion, but that alleviates many > problems. What I usually do is to NULL out the entire structure (or whatever) that is being pointed at before freeing it. This does not prevent an aliased access, but it does increase the probability of it being noticed as soon as possible. JAS