how to avoid visiting a freed address?

view story

http://stackoverflow.com – The program will run normally when I try to visit an address which is already freed. Is there some goods to avoid? like some function named have_alloca(void *p) can return whether p is a valid address. I know that valgrind with tool=memcheck can do that. But I want to know if I can avoid it from code. here is a simple example: #include <stdlib.h> int main(int argc, char *argv[]) { int *p = malloc(sizeof(int) * 10); free(p); *(p + 1) = 100; return 0; } Why I can visit a invalid address? and the program can compile and run without any warns. BTW: Linux. (HowTos)