fixed p_to_free potential crash bug