Re: writing to freed memory--issues
- From: Måns Rullgård <mru@xxxxxxxxxxxxx>
- Date: Mon, 27 Mar 2006 21:06:39 +0100
"bill pursell" <bill.pursell@xxxxxxxxx> writes:
I was playing around with a toy program, which led to some confusion.
I had expected that doing the following would lead to an immediate
segfault:
free(a);
*a=0;
However, it did not. Further investigation showed that I could free a
Don't bother. Accessing freed memory causes undefined behavior. It
might work (as in load instructions completing normally), or it might
segfault, or it might turn you into a toad. Exactly what happens
depends on your operating system and malloc() implementation, among
many other factors.
The only thing you need to know is that accessing freed memory is
*never* a valid thing to do.
--
Måns Rullgård
mru@xxxxxxxxxxxxx
.
- References:
- writing to freed memory--issues
- From: bill pursell
- writing to freed memory--issues
- Prev by Date: writing to freed memory--issues
- Next by Date: Re: writing to freed memory--issues
- Previous by thread: writing to freed memory--issues
- Next by thread: Re: writing to freed memory--issues
- Index(es):