cfgparser: fix some memory leaks