[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: false asumption or security flaw?



Sorry, I may have misunderstood what you were trying to do. In any case,
playing with pointers after they've been freed is a big no-no. I usually
give them the value NULL to 1) make it a lot more likely that access to
the pointer causes some kind of runtime error (segfault, perhaps) and
2) to mark the pointer as unused.

int *x;
if ((x = malloc (sizeof (int))) == NULL)
    abort ();
*x = 42;
free (x);
x = NULL; /* !!! */
*x = 24; /* kaboom */

Tim

--
Tim Robbins
fyre@box3n.gumbynet.org



Kernel-audit:  discussion list for security and the linux kernel
Archive:       http://mail.nl.linux.org/kernel-audit/