Most people do this because they usually have error handling otherwise (besides this I really don't see the point of doing a check). In some cases, they do this to verify that they are freeing something, and not accidentally changing the pointer somewhere and causing a memory leak without freeing it. free(NULL); should work in all cases, and not with an error, therefore, if there is no error handling in it, you can delete the if statement and just make it free.
source share