fix resource leak when loading config file