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

Commit 138184a

Browse files
committed
Plug memory leak when reloading config file.
The absolute path to config file was not pfreed. There are probably more small leaks here and there in the config file reload code and assign hooks, and in practice no-one reloads the config files frequently enough for it to be a problem, but this one is trivial enough that might as well fix it. Backpatch to 9.3 where the leak was introduced.
1 parent bb59845 commit 138184a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
409409
ConfigVariable **head_p,
410410
ConfigVariable **tail_p)
411411
{
412+
char *abs_path;
412413
bool OK = true;
413414
FILE *fp;
414415

@@ -426,28 +427,29 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
426427
return false;
427428
}
428429

429-
config_file = AbsoluteConfigLocation(config_file,calling_file);
430-
fp = AllocateFile(config_file, "r");
430+
abs_path = AbsoluteConfigLocation(config_file, calling_file);
431+
fp = AllocateFile(abs_path, "r");
431432
if (!fp)
432433
{
433434
if (strict)
434435
{
435436
ereport(elevel,
436437
(errcode_for_file_access(),
437438
errmsg("could not open configuration file \"%s\": %m",
438-
config_file)));
439+
abs_path)));
439440
return false;
440441
}
441442

442443
ereport(LOG,
443444
(errmsg("skipping missing configuration file \"%s\"",
444-
config_file)));
445+
abs_path)));
445446
return OK;
446447
}
447448

448-
OK = ParseConfigFp(fp, config_file, depth, elevel, head_p, tail_p);
449+
OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p);
449450

450451
FreeFile(fp);
452+
pfree(abs_path);
451453

452454
return OK;
453455
}

0 commit comments

Comments
 (0)