fix leaks on error to open.