fix memory leak on master