If you have something which contains pointers, you should have a destructor function for it, which itself should check if the pointer is not NULL before attempting to free any fields.
I just mean, in the simple English sense, a function which exists to deallocate a structure.