Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bcc87b6

Browse files
committed
Fix assorted memory leaks.
Per Coverity (not that any of these are so non-obvious that they should not have been caught before commit). The extent of leakage is probably minor to unnoticeable, but a leak is a leak. Back-patch as necessary. Michael Paquier
1 parent 3ed26e5 commit bcc87b6

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/bin/pg_basebackup/streamutil.c

+1
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ DropReplicationSlot(PGconn *conn, const char *slot_name)
414414
return false;
415415
}
416416

417+
destroyPQExpBuffer(query);
417418
PQclear(res);
418419
return true;
419420
}

src/bin/pg_dump/pg_dump.c

+2
Original file line numberDiff line numberDiff line change
@@ -6660,6 +6660,7 @@ getTransforms(Archive *fout, int *numTransforms)
66606660
appendPQExpBuffer(&namebuf, "%s %s",
66616661
typeInfo->dobj.name, lanname);
66626662
transforminfo[i].dobj.name = namebuf.data;
6663+
free(lanname);
66636664
}
66646665

66656666
PQclear(res);
@@ -15735,6 +15736,7 @@ getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[]
1573515736
addObjectDependency(&contable->dataObj->dobj,
1573615737
reftable->dataObj->dobj.dumpId);
1573715738
}
15739+
PQclear(res);
1573815740
destroyPQExpBuffer(query);
1573915741
}
1574015742

src/bin/pg_rewind/libpq_fetch.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ libpqConnect(const char *connstr)
6969
pg_free(str);
7070

7171
/*
72-
* Also check that full_page_writes is enabled. We can get torn pages if
72+
* Also check that full_page_writes is enabled. We can get torn pages if
7373
* a page is modified while we read it with pg_read_binary_file(), and we
7474
* rely on full page images to fix them.
7575
*/
@@ -81,6 +81,7 @@ libpqConnect(const char *connstr)
8181

8282
/*
8383
* Runs a query that returns a single value.
84+
* The result should be pg_free'd after use.
8485
*/
8586
static char *
8687
run_simple_query(const char *sql)
@@ -123,6 +124,8 @@ libpqGetCurrentXlogInsertLocation(void)
123124

124125
result = ((uint64) hi) << 32 | lo;
125126

127+
pg_free(val);
128+
126129
return result;
127130
}
128131

@@ -201,6 +204,7 @@ libpqProcessFileList(void)
201204

202205
process_source_file(path, type, filesize, link_target);
203206
}
207+
PQclear(res);
204208
}
205209

206210
/*----
@@ -296,7 +300,7 @@ receiveFileChunks(const char *sql)
296300
if (PQgetisnull(res, 0, 2))
297301
{
298302
pg_log(PG_DEBUG,
299-
"received NULL chunk for file \"%s\", file has been deleted\n",
303+
"received NULL chunk for file \"%s\", file has been deleted\n",
300304
filename);
301305
pg_free(filename);
302306
PQclear(res);

src/bin/scripts/vacuumdb.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
393393
for (i = 0; i < ntups; i++)
394394
{
395395
appendPQExpBufferStr(&buf,
396-
fmtQualifiedId(PQserverVersion(conn),
397-
PQgetvalue(res, i, 1),
398-
PQgetvalue(res, i, 0)));
396+
fmtQualifiedId(PQserverVersion(conn),
397+
PQgetvalue(res, i, 1),
398+
PQgetvalue(res, i, 0)));
399399

400400
simple_string_list_append(&dbtables, buf.data);
401401
resetPQExpBuffer(&buf);
@@ -412,6 +412,7 @@ vacuum_one_database(const char *dbname, vacuumingOptions *vacopts,
412412
concurrentCons = ntups;
413413
if (concurrentCons <= 1)
414414
parallel = false;
415+
PQclear(res);
415416
}
416417

417418
/*

0 commit comments

Comments
 (0)