@@ -469,18 +469,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
469469(errcode_for_file_access (),
470470errmsg (" could not open configuration file\" %s\" : %m" ,
471471abs_path)));
472- return false ;
472+ OK =false ;
473+ goto cleanup;
473474}
474475
475476ereport (LOG,
476477(errmsg (" skipping missing configuration file\" %s\" " ,
477478abs_path)));
478- return OK;
479+ OK =true ;
480+ goto cleanup;
479481}
480482
481483OK =ParseConfigFp (fp, abs_path, depth, elevel, head_p, tail_p);
482484
483- FreeFile (fp);
485+ cleanup:
486+ if (fp)
487+ FreeFile (fp);
484488pfree (abs_path);
485489
486490return OK;
@@ -748,7 +752,8 @@ ParseConfigDirectory(const char *includedir,
748752(errcode_for_file_access (),
749753errmsg (" could not open configuration directory\" %s\" : %m" ,
750754directory)));
751- return false ;
755+ status =false ;
756+ goto cleanup;
752757}
753758
754759/*
@@ -803,7 +808,8 @@ ParseConfigDirectory(const char *includedir,
803808(errcode_for_file_access (),
804809errmsg (" could not stat file\" %s\" : %m" ,
805810filename)));
806- return false ;
811+ status =false ;
812+ goto cleanup;
807813}
808814}
809815
@@ -824,7 +830,9 @@ ParseConfigDirectory(const char *includedir,
824830status =true ;
825831
826832cleanup:
827- FreeDir (d);
833+ if (d)
834+ FreeDir (d);
835+ pfree (directory);
828836return status;
829837}
830838