Re: free()



Ian Collins <ian-news@xxxxxxxxxxx> wrote:

Richard Bos wrote:

The problem with that is "attempting". You will, sooner or later, fail
in your attempt. And then, because you believe that all your pointers
are either null or valid, you will not be able to find the bug until

Can you cite an example where setting a pointer to NULL could mask a
bug? The way I see it is there are three things you can do with a
pointer, test it, dereference it and free it. Once set to NULL, the
first to will fail and the third is harmless.

You missed Richard's point. The problem lies not in setting the
pointer to NULL, but in *believing* one has when in fact one has not.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
.



Relevant Pages

  • Re: OT: my new PC rocks!!
    ... Microsoft basically "owns" the ACPM thing and has the hardware ... for practically everything;) doing all the work and the "Windows" bit ... is merely the pretty graphics and mouse pointer routines to stare at ... actually seen it up and running to test if this "bug" is even older ...
    (alt.lang.asm)
  • Re: Unhandled exception on clicking dialog box OK button,Its URGENT
    ... impression that the text is a bstr, and how large are those buffers, and why do you ... pointer; and the second suspicition is that it is a pointer to a buffer that is too small. ... What was the call stack trace, and what were the values of the variables ... You have to do SOMETHING besides say "my program has a bug, ...
    (microsoft.public.vc.mfc)
  • Re: Real pain with SegFoult
    ... For three days I'am looking for a bug, but I'm not able to find it. ... Only leave the correct casts in place. ... look at every single pointer usage. ... assumption is correct, the assertion will never, ever fire. ...
    (comp.lang.c)
  • Re: Security fix for remapping of page 0 (was [PATCH] Change ZERO_SIZE_PTR to point at unmapped spac
    ... case of kernel bug to get to that NULL pointer (or zero-sized-alloc ... this whole discussion about NULL derefs is quite missing the point by the way. ... the proper bug class is about unintended userland ptr derefs by the kernel, ... it by default or otherwise by banning userland from using its address space;). ...
    (Linux-Kernel)
  • Re: First things you check for when youve got errors
    ... implicit int and also implicit function declarations via the compiler ... So that's always my first focus. ... If you are good about always either destroying or setting invalid pointers to null you will only occasionally get a sefault due to a wild pointer. ... However if you get a really difficult bug, with wrong output popping up seemingly from nowhere, probably it is due to a pointer pointing into memory that you own but have reallocated for another purpose. ...
    (comp.lang.c)