fix memory leaks in config loader (bug #4223)