@@ -437,18 +437,22 @@ ParseConfigFile(const char *config_file, const char *calling_file, bool strict,
437437(errcode_for_file_access (),
438438errmsg (" could not open configuration file\" %s\" : %m" ,
439439abs_path)));
440- return false ;
440+ OK =false ;
441+ goto cleanup;
441442}
442443
443444ereport (LOG,
444445(errmsg (" skipping missing configuration file\" %s\" " ,
445446abs_path)));
446- return OK;
447+ OK =true ;
448+ goto cleanup;
447449}
448450
449451OK =ParseConfigFp (fp, abs_path, depth, elevel, head_p, tail_p);
450452
451- FreeFile (fp);
453+ cleanup:
454+ if (fp)
455+ FreeFile (fp);
452456pfree (abs_path);
453457
454458return OK;
@@ -716,7 +720,8 @@ ParseConfigDirectory(const char *includedir,
716720(errcode_for_file_access (),
717721errmsg (" could not open configuration directory\" %s\" : %m" ,
718722directory)));
719- return false ;
723+ status =false ;
724+ goto cleanup;
720725}
721726
722727/*
@@ -771,7 +776,8 @@ ParseConfigDirectory(const char *includedir,
771776(errcode_for_file_access (),
772777errmsg (" could not stat file\" %s\" : %m" ,
773778filename)));
774- return false ;
779+ status =false ;
780+ goto cleanup;
775781}
776782}
777783
@@ -792,7 +798,9 @@ ParseConfigDirectory(const char *includedir,
792798status =true ;
793799
794800cleanup:
795- FreeDir (d);
801+ if (d)
802+ FreeDir (d);
803+ pfree (directory);
796804return status;
797805}
798806