fix memory error