fix memory leak on upload