SERVER-8765 fix memory leaks in config upgrade codepath