Fix memory leak on early return