Skip to content

Commit ed07361

Browse files
committed
Don't leak memory during failure exit from SelectConfigFiles().
Make sure the memory allocated by make_absolute_path() is freed when SelectConfigFiles() fails. Since all the callers will exit immediately in that case, there's no practical gain here, but silencing Valgrind leak complaints seems useful. In any case, it was inconsistent that only one of the failure exits did this. Author: Aleksander Alekseev <aleksander@tigerdata.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAJ7c6TMByXE8dc7zDvDWTQjk6o-XXAdRg_RAg5CBaUOgFPV3LQ%40mail.gmail.com
1 parent 4ec6e22 commit ed07361

File tree

1 file changed

+11
-7
lines changed
  • src/backend/utils/misc

1 file changed

+11
-7
lines changed

src/backend/utils/misc/guc.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)
18031803
configdir);
18041804
if (errno == ENOENT)
18051805
write_stderr("Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
1806-
return false;
1806+
goto fail;
18071807
}
18081808

18091809
/*
@@ -1830,7 +1830,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)
18301830
"You must specify the --config-file or -D invocation "
18311831
"option or set the PGDATA environment variable.\n",
18321832
progname);
1833-
return false;
1833+
goto fail;
18341834
}
18351835

18361836
/*
@@ -1851,8 +1851,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)
18511851
{
18521852
write_stderr("%s: could not access the server configuration file \"%s\": %m\n",
18531853
progname, ConfigFileName);
1854-
free(configdir);
1855-
return false;
1854+
goto fail;
18561855
}
18571856

18581857
/*
@@ -1882,7 +1881,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)
18821881
"or by the -D invocation option, or by the "
18831882
"PGDATA environment variable.\n",
18841883
progname, ConfigFileName);
1885-
return false;
1884+
goto fail;
18861885
}
18871886

18881887
/*
@@ -1934,7 +1933,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)
19341933
"or by the -D invocation option, or by the "
19351934
"PGDATA environment variable.\n",
19361935
progname, ConfigFileName);
1937-
return false;
1936+
goto fail;
19381937
}
19391938
SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
19401939

@@ -1965,7 +1964,7 @@ SelectConfigFiles(const char *userDoption, const char *progname)
19651964
"or by the -D invocation option, or by the "
19661965
"PGDATA environment variable.\n",
19671966
progname, ConfigFileName);
1968-
return false;
1967+
goto fail;
19691968
}
19701969
SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
19711970

@@ -1977,6 +1976,11 @@ SelectConfigFiles(const char *userDoption, const char *progname)
19771976
free(configdir);
19781977

19791978
return true;
1979+
1980+
fail:
1981+
free(configdir);
1982+
1983+
return false;
19801984
}
19811985

19821986
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy