Error checking to make sure we don't deallocate unallocated memory