fix a leak on error