Skip to content

Commit

Permalink
pg_dump: Don't leak memory in buildDefaultACLCommands()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sfrost committed May 7, 2017
1 parent 92b1522 commit ef42c11
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bin/pg_dump/dumputils.c
Expand Up @@ -394,13 +394,19 @@ buildDefaultACLCommands(const char *type, const char *nspname,
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
if (!buildACLCommands("", NULL, type, initacls, initracls, owner,
prefix->data, remoteVersion, sql))
{
destroyPQExpBuffer(prefix);
return false;
}
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
}

if (!buildACLCommands("", NULL, type, acls, racls, owner,
prefix->data, remoteVersion, sql))
{
destroyPQExpBuffer(prefix);
return false;
}

destroyPQExpBuffer(prefix);

Expand Down

0 comments on commit ef42c11

Please sign in to comment.