C Language Undefined behavior Freeing memory twice


Freeing memory twice is undefined behavior, e.g.

int * x = malloc(sizeof(int));
*x = 9;

Quote from standard( The free function of C99 ):

Otherwise, if the argument does not match a pointer earlier returned by the calloc, malloc, or realloc function, or if the space has been deallocated by a call to free or realloc, the behavior is undefined.