]> granicus.if.org Git - postgresql/commitdiff
Plug more memory leaks when reloading config file.
authorRobert Haas <rhaas@postgresql.org>
Tue, 21 Jan 2014 14:41:40 +0000 (09:41 -0500)
committerRobert Haas <rhaas@postgresql.org>
Tue, 21 Jan 2014 14:41:40 +0000 (09:41 -0500)
Commit 138184adc5f7c60c184972e4d23f8cdb32aed77d plugged some but not
all of the leaks from commit 2a0c81a12c7e6c5ac1557b0f1f4a581f23fd4ca7.
This tightens things up some more.

Amit Kapila, per an observation by Tom Lane

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

index ec9e0322021b87fbeed9fa2c29eb1b0d3f3a76c1..a5b9d6ac77cc2c947e64f9c826400d70bb32989d 100644 (file)
@@ -469,18 +469,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
                                        (errcode_for_file_access(),
                                         errmsg("could not open configuration file \"%s\": %m",
                                                        abs_path)));
-                       return false;
+                       OK = false;
+                       goto cleanup;
                }
 
                ereport(LOG,
                                (errmsg("skipping missing configuration file \"%s\"",
                                                abs_path)));
-               return OK;
+               OK = true;
+               goto cleanup;
        }
 
        OK = ParseConfigFp(fp, abs_path, depth, elevel, head_p, tail_p);
 
-       FreeFile(fp);
+cleanup:
+       if (fp)
+               FreeFile(fp);
        pfree(abs_path);
 
        return OK;
@@ -748,7 +752,8 @@ ParseConfigDirectory(const char *includedir,
                                (errcode_for_file_access(),
                                 errmsg("could not open configuration directory \"%s\": %m",
                                                directory)));
-               return false;
+               status = false;
+               goto cleanup;
        }
 
        /*
@@ -803,7 +808,8 @@ ParseConfigDirectory(const char *includedir,
                                        (errcode_for_file_access(),
                                         errmsg("could not stat file \"%s\": %m",
                                                        filename)));
-                       return false;
+                       status = false;
+                       goto cleanup;
                }
        }
 
@@ -824,7 +830,9 @@ ParseConfigDirectory(const char *includedir,
        status = true;
 
 cleanup:
-       FreeDir(d);
+       if (d)
+               FreeDir(d);
+       pfree(directory);
        return status;
 }