Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit91cbb4b

Browse files
committed
Fix assorted resource leaks in new pg_createsubscriber code.
Various error paths did not release resources before returning.While it's likely that the program would just exit shortly later,none of the functions in question have summary exit(1) calls,so they should not be assuming that.Ranier Vilela and Tom Lane, per reports from CoverityDiscussion:https://postgr.es/m/CAEudQAr2_SZFxB4kXJiL4+2UaNZxUk5UBJtj0oXyJYMGZu-03g@mail.gmail.com
1 parent6f47f68 commit91cbb4b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

‎src/bin/pg_basebackup/pg_createsubscriber.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ usage(void)
251251
staticchar*
252252
get_base_conninfo(constchar*conninfo,char**dbname)
253253
{
254-
PQExpBufferbuf=createPQExpBuffer();
255-
PQconninfoOption*conn_opts=NULL;
254+
PQExpBufferbuf;
255+
PQconninfoOption*conn_opts;
256256
PQconninfoOption*conn_opt;
257257
char*errmsg=NULL;
258258
char*ret;
@@ -262,9 +262,11 @@ get_base_conninfo(const char *conninfo, char **dbname)
262262
if (conn_opts==NULL)
263263
{
264264
pg_log_error("could not parse connection string: %s",errmsg);
265+
PQfreemem(errmsg);
265266
returnNULL;
266267
}
267268

269+
buf=createPQExpBuffer();
268270
i=0;
269271
for (conn_opt=conn_opts;conn_opt->keyword!=NULL;conn_opt++)
270272
{
@@ -497,9 +499,10 @@ connect_database(const char *conninfo, bool exit_on_error)
497499
{
498500
pg_log_error("connection to database failed: %s",
499501
PQerrorMessage(conn));
502+
PQfinish(conn);
503+
500504
if (exit_on_error)
501505
exit(1);
502-
503506
returnNULL;
504507
}
505508

@@ -509,9 +512,11 @@ connect_database(const char *conninfo, bool exit_on_error)
509512
{
510513
pg_log_error("could not clear search_path: %s",
511514
PQresultErrorMessage(res));
515+
PQclear(res);
516+
PQfinish(conn);
517+
512518
if (exit_on_error)
513519
exit(1);
514-
515520
returnNULL;
516521
}
517522
PQclear(res);
@@ -941,6 +946,8 @@ check_publisher(const struct LogicalRepInfo *dbinfo)
941946
failed= true;
942947
}
943948

949+
pg_free(wal_level);
950+
944951
if (failed)
945952
exit(1);
946953
}
@@ -1209,6 +1216,8 @@ create_logical_replication_slot(PGconn *conn, struct LogicalRepInfo *dbinfo)
12091216
pg_log_error("could not create replication slot \"%s\" on database \"%s\": %s",
12101217
slot_name,dbinfo->dbname,
12111218
PQresultErrorMessage(res));
1219+
PQclear(res);
1220+
destroyPQExpBuffer(str);
12121221
returnNULL;
12131222
}
12141223

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp