display_error_conf_filename_v2.patch
application/octet-stream
Filename: display_error_conf_filename_v2.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
Series: patch v2
| File | + | − |
|---|---|---|
| src/backend/utils/misc/guc-file.l | 11 | 6 |
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index c452a0a..bf57e3c 100644
--- a/src/backend/utils/misc/guc-file.l
+++ b/src/backend/utils/misc/guc-file.l
@@ -120,7 +120,6 @@ ProcessConfigFile(GucContext context)
*head,
*tail;
int i;
- char ConfigAutoFileName[MAXPGPATH];
char *ErrorConfFile;
char *CallingFileName;
@@ -155,17 +154,16 @@ ProcessConfigFile(GucContext context)
* data directory, however when called during initdb data directory is not
* set till this point, so use ConfigFile path which will be same.
*/
- snprintf(ConfigAutoFileName,sizeof(ConfigAutoFileName),"%s", PG_AUTOCONF_FILENAME);
if (data_directory)
CallingFileName = NULL;
else
CallingFileName = ConfigFileName;
- if (!ParseConfigFile(ConfigAutoFileName, CallingFileName, false, 0, elevel, &head, &tail))
+ if (!ParseConfigFile(PG_AUTOCONF_FILENAME, CallingFileName, false, 0, elevel, &head, &tail))
{
/* Syntax error(s) detected in the file, so bail out */
error = true;
- ErrorConfFile = ConfigAutoFileName;
+ ErrorConfFile = PG_AUTOCONF_FILENAME;
goto cleanup_list;
}
@@ -368,8 +366,6 @@ ProcessConfigFile(GucContext context)
PgReloadTime = GetCurrentTimestamp();
cleanup_list:
- FreeConfigVariables(head);
-
if (error)
{
/* During postmaster startup, any error is fatal */
@@ -389,6 +385,15 @@ ProcessConfigFile(GucContext context)
errmsg("configuration file \"%s\" contains errors; no changes were applied",
ErrorConfFile)));
}
+
+ /*
+ * Freeing the config variables after error can cause leak,
+ * incase error is reported with level as ERROR. Currently
+ * the only case when it can happen is during postmaster
+ * startup at which it upgrades the error to FATAL which
+ * will anyway close the process.
+ */
+ FreeConfigVariables(head);
}
/*