fix double free in error state