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

Commit ef42c11

Browse files
committed
pg_dump: Don't leak memory in buildDefaultACLCommands()
buildDefaultACLCommands() didn't destroy the string buffer created in certain cases, leading to a memory leak. Fix by destroying the buffer before returning from the function. Spotted by Coverity. Author: Michael Paquier Back-patch to 9.6 where buildDefaultACLCommands() was added.
1 parent 92b1522 commit ef42c11

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/bin/pg_dump/dumputils.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,19 @@ buildDefaultACLCommands(const char *type, const char *nspname,
394394
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
395395
if (!buildACLCommands("", NULL, type, initacls, initracls, owner,
396396
prefix->data, remoteVersion, sql))
397+
{
398+
destroyPQExpBuffer(prefix);
397399
return false;
400+
}
398401
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
399402
}
400403

401404
if (!buildACLCommands("", NULL, type, acls, racls, owner,
402405
prefix->data, remoteVersion, sql))
406+
{
407+
destroyPQExpBuffer(prefix);
403408
return false;
409+
}
404410

405411
destroyPQExpBuffer(prefix);
406412

0 commit comments

Comments
 (0)