What happens when free(NULL) is called in C?
Correct answer D. Nothing; the call has no effect
Explanation
The C standard states that if the argument to free is a null pointer, no action occurs. This lets clean-up code call free on pointers that may never have been allocated without checking first. Setting a pointer to NULL after freeing it is a common habit for this reason, because freeing the same non-null pointer twice is undefined behaviour.
Answer checked How we write and check questions
Discussion