What does the C standard say happens if free() is called twice on the same pointer without reallocating it?
Correct answer B. The behaviour is undefined
Explanation
After the first free, the pointer no longer refers to an allocated block, and passing it to free again is undefined behaviour. It may corrupt the allocator's internal data and is a known security weakness. free(NULL) is the safe exception, which is why setting a pointer to NULL immediately after freeing it guards against double frees.
Answer checked How we write and check questions
Discussion