]> granicus.if.org Git - postgresql/commitdiff
Plug memory leak when reloading config file.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 24 Oct 2013 12:21:50 +0000 (15:21 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 24 Oct 2013 12:27:40 +0000 (15:27 +0300)
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.

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

index b730a120d8e2d7d67501eb879a5f93b51febecea..c5ca4a40742b3a8fdd4bb555731a1032af3de130 100644 (file)
@@ -409,6 +409,7 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
                                ConfigVariable **head_p,
                                ConfigVariable **tail_p)
 {
+       char       *abs_path;
        bool            OK = true;
        FILE       *fp;
 
@@ -426,8 +427,8 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
                return false;
        }
 
-       config_file = AbsoluteConfigLocation(config_file,calling_file);
-       fp = AllocateFile(config_file, "r");
+       abs_path = AbsoluteConfigLocation(config_file, calling_file);
+       fp = AllocateFile(abs_path, "r");
        if (!fp)
        {
                if (strict)
@@ -435,19 +436,20 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
                        ereport(elevel,
                                        (errcode_for_file_access(),
                                         errmsg("could not open configuration file \"%s\": %m",
-                                                       config_file)));
+                                                       abs_path)));
                        return false;
                }
 
                ereport(LOG,
                                (errmsg("skipping missing configuration file \"%s\"",
-                                               config_file)));
+                                               abs_path)));
                return OK;
        }
 
-       OK = ParseConfigFp(fp, config_file, depth, elevel, head_p, tail_p);
+       OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p);
 
        FreeFile(fp);
+       pfree(abs_path);
 
        return OK;
 }