Fix a double free on error recovering