i was running a small c program:
#include<stdio.h>
int main()
{
char *p;
p = (char *)malloc(10);
free(p);
free(p);
free(p);
printf("\npointer is freed!!\n");
}
basically i am freeing the memory which has already been freed. i think should result in a core dump!!is it not so?
but it is printing the
pointer is freed!!
am i wrong some where?
As per the man page, "if free(ptr) has already been called before, undefined behavior occurs."
It doesn't need to blow up; "not doing anything" is perfectly acceptable undefined behaviour. Also are nasal demons. Don't rely on it.