summaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/guc-file.l
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-01-13 14:54:00 -0500
committerRobert Haas <rhaas@postgresql.org>2014-01-13 14:54:00 -0500
commit05ff5062da5fb4b0c950260ed12af0ae5d8932a4 (patch)
treed353c68dd4033c5137a2aafe1afe45e1045ae357 /src/backend/utils/misc/guc-file.l
parent2bb1f14b89deacd1142b4a06bcb1a52a76270449 (diff)
downloadpostgresql-05ff5062da5fb4b0c950260ed12af0ae5d8932a4.tar.gz
Code improvements for ALTER SYSTEM .. SET.
Move FreeConfigVariables() later to make sure ErrorConfFile is valid when we use it, and get rid of an unnecessary string copy operation. Amit Kapila, kibitzed by me.
Diffstat (limited to 'src/backend/utils/misc/guc-file.l')
-rw-r--r--src/backend/utils/misc/guc-file.l15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l
index c452a0ac0d..ec9e032202 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,13 @@ ProcessConfigFile(GucContext context)
errmsg("configuration file \"%s\" contains errors; no changes were applied",
ErrorConfFile)));
}
+
+ /*
+ * Calling FreeConfigVariables() any earlier than this can cause problems,
+ * because ErrorConfFile could be pointing to a string that will be freed
+ * here.
+ */
+ FreeConfigVariables(head);
}
/*