BUG/MINOR: cfgparse: couple of small memory leaks.
During the config parse in some code paths, there is some
forgotten pointers freeing, and as often, during errors handlings.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index abe2fe8..2d0a020 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1611,8 +1611,10 @@
arg += 2;
}
- if (alertif_too_many_args_idx(3, arg + 1, file, linenum, args, &err_code))
+ if (alertif_too_many_args_idx(3, arg + 1, file, linenum, args, &err_code)) {
+ free(logsrv);
goto out;
+ }
logsrv->facility = get_log_facility(args[arg+2]);
if (logsrv->facility < 0) {
@@ -6793,6 +6795,7 @@
if (!newul->name) {
Alert("parsing [%s:%d]: out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT;
+ free(newul);
goto out;
}
@@ -6978,8 +6981,10 @@
!cfg_register_section("resolvers", cfg_parse_resolvers))
return -1;
- if ((f=fopen(file,"r")) == NULL)
+ if ((f=fopen(file,"r")) == NULL) {
+ free(thisline);
return -1;
+ }
next_line:
while (fgets(thisline + readbytes, linesize - readbytes, f) != NULL) {