Commit a5bca4ef authored by Robert Haas's avatar Robert Haas

Plug more memory leaks when reloading config file.

Commit 138184ad plugged some but not
all of the leaks from commit 2a0c81a1.
This tightens things up some more.

Amit Kapila, per an observation by Tom Lane
parent d2458e3b
...@@ -469,18 +469,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict, ...@@ -469,18 +469,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not open configuration file \"%s\": %m", errmsg("could not open configuration file \"%s\": %m",
abs_path))); abs_path)));
return false; OK = false;
goto cleanup;
} }
ereport(LOG, ereport(LOG,
(errmsg("skipping missing configuration file \"%s\"", (errmsg("skipping missing configuration file \"%s\"",
abs_path))); abs_path)));
return OK; OK = true;
goto cleanup;
} }
OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p); OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p);
FreeFile(fp); cleanup:
if (fp)
FreeFile(fp);
pfree(abs_path); pfree(abs_path);
return OK; return OK;
...@@ -748,7 +752,8 @@ ParseConfigDirectory(const char *includedir, ...@@ -748,7 +752,8 @@ ParseConfigDirectory(const char *includedir,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not open configuration directory \"%s\": %m", errmsg("could not open configuration directory \"%s\": %m",
directory))); directory)));
return false; status = false;
goto cleanup;
} }
/* /*
...@@ -803,7 +808,8 @@ ParseConfigDirectory(const char *includedir, ...@@ -803,7 +808,8 @@ ParseConfigDirectory(const char *includedir,
(errcode_for_file_access(), (errcode_for_file_access(),
errmsg("could not stat file \"%s\": %m", errmsg("could not stat file \"%s\": %m",
filename))); filename)));
return false; status = false;
goto cleanup;
} }
} }
...@@ -824,7 +830,9 @@ ParseConfigDirectory(const char *includedir, ...@@ -824,7 +830,9 @@ ParseConfigDirectory(const char *includedir,
status = true; status = true;
cleanup: cleanup:
FreeDir(d); if (d)
FreeDir(d);
pfree(directory);
return status; return status;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment