(hash_clear): Fix a bug that could lead to an infloop or e.g., a fault due to an attempt to free a NULL pointer.