Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a5bca4e

Browse files
committed
Plug more memory leaks when reloading config file.
Commit 138184a plugged some but not all of the leaks from commit 2a0c81a. This tightens things up some more. Amit Kapila, per an observation by Tom Lane
1 parent d2458e3 commit a5bca4e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/backend/utils/misc/guc-file.l

+14-6
Original file line numberDiff line numberDiff line change
@@ -469,18 +469,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
469469
(errcode_for_file_access(),
470470
errmsg("could not open configuration file \"%s\": %m",
471471
abs_path)));
472-
return false;
472+
OK = false;
473+
goto cleanup;
473474
}
474475

475476
ereport(LOG,
476477
(errmsg("skipping missing configuration file \"%s\"",
477478
abs_path)));
478-
return OK;
479+
OK = true;
480+
goto cleanup;
479481
}
480482

481483
OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p);
482484

483-
FreeFile(fp);
485+
cleanup:
486+
if (fp)
487+
FreeFile(fp);
484488
pfree(abs_path);
485489

486490
return OK;
@@ -748,7 +752,8 @@ ParseConfigDirectory(const char *includedir,
748752
(errcode_for_file_access(),
749753
errmsg("could not open configuration directory \"%s\": %m",
750754
directory)));
751-
return false;
755+
status = false;
756+
goto cleanup;
752757
}
753758

754759
/*
@@ -803,7 +808,8 @@ ParseConfigDirectory(const char *includedir,
803808
(errcode_for_file_access(),
804809
errmsg("could not stat file \"%s\": %m",
805810
filename)));
806-
return false;
811+
status = false;
812+
goto cleanup;
807813
}
808814
}
809815

@@ -824,7 +830,9 @@ ParseConfigDirectory(const char *includedir,
824830
status = true;
825831

826832
cleanup:
827-
FreeDir(d);
833+
if (d)
834+
FreeDir(d);
835+
pfree(directory);
828836
return status;
829837
}
830838

0 commit comments

Comments
 (0)