From a5bca4ef034f71175d46462963af2329d22068c2 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 21 Jan 2014 09:41:40 -0500 Subject: [PATCH] Plug more memory leaks when reloading config file. Commit 138184adc5f7c60c184972e4d23f8cdb32aed77d plugged some but not all of the leaks from commit 2a0c81a12c7e6c5ac1557b0f1f4a581f23fd4ca7. This tightens things up some more. Amit Kapila, per an observation by Tom Lane --- src/backend/utils/misc/guc-file.l | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index ec9e032202..a5b9d6ac77 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -469,18 +469,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict, (errcode_for_file_access(), errmsg("could not open configuration file \"%s\": %m", abs_path))); - return false; + OK = false; + goto cleanup; } ereport(LOG, (errmsg("skipping missing configuration file \"%s\"", abs_path))); - return OK; + OK = true; + goto cleanup; } OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p); - FreeFile(fp); +cleanup: + if (fp) + FreeFile(fp); pfree(abs_path); return OK; @@ -748,7 +752,8 @@ ParseConfigDirectory(const char *includedir, (errcode_for_file_access(), errmsg("could not open configuration directory \"%s\": %m", directory))); - return false; + status = false; + goto cleanup; } /* @@ -803,7 +808,8 @@ ParseConfigDirectory(const char *includedir, (errcode_for_file_access(), errmsg("could not stat file \"%s\": %m", filename))); - return false; + status = false; + goto cleanup; } } @@ -824,7 +830,9 @@ ParseConfigDirectory(const char *includedir, status = true; cleanup: - FreeDir(d); + if (d) + FreeDir(d); + pfree(directory); return status; } -- 2.40.0