@@ -120,7 +120,6 @@ ProcessConfigFile(GucContext context)
120120 *head,
121121 *tail;
122122 int i;
123- char ConfigAutoFileName[MAXPGPATH];
124123 char *ErrorConfFile;
125124 char *CallingFileName;
126125
@@ -155,17 +154,16 @@ ProcessConfigFile(GucContext context)
155154 * data directory, however when called during initdb data directory is not
156155 * set till this point, so use ConfigFile path which will be same.
157156 */
158- snprintf(ConfigAutoFileName,sizeof(ConfigAutoFileName),"%s", PG_AUTOCONF_FILENAME);
159157 if (data_directory)
160158 CallingFileName = NULL;
161159 else
162160 CallingFileName = ConfigFileName;
163161
164- if (!ParseConfigFile(ConfigAutoFileName , CallingFileName, false, 0, elevel, &head, &tail))
162+ if (!ParseConfigFile(PG_AUTOCONF_FILENAME , CallingFileName, false, 0, elevel, &head, &tail))
165163 {
166164 /* Syntax error(s) detected in the file, so bail out */
167165 error = true;
168- ErrorConfFile = ConfigAutoFileName ;
166+ ErrorConfFile = PG_AUTOCONF_FILENAME ;
169167 goto cleanup_list;
170168 }
171169
@@ -368,8 +366,6 @@ ProcessConfigFile(GucContext context)
368366 PgReloadTime = GetCurrentTimestamp();
369367
370368 cleanup_list:
371- FreeConfigVariables (head);
372-
373369 if (error)
374370 {
375371 /* During postmaster startup, any error is fatal */
@@ -389,6 +385,13 @@ ProcessConfigFile(GucContext context)
389385 errmsg (" configuration file \" %s\" contains errors; no changes were applied" ,
390386 ErrorConfFile)));
391387 }
388+
389+ /*
390+ * Calling FreeConfigVariables() any earlier than this can cause problems,
391+ * because ErrorConfFile could be pointing to a string that will be freed
392+ * here.
393+ */
394+ FreeConfigVariables (head);
392395}
393396
394397/*
0 commit comments