Commit 09f84218 authored by Stephen Frost's avatar Stephen Frost

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.
parent aa5d3c0b
...@@ -390,13 +390,19 @@ buildDefaultACLCommands(const char *type, const char *nspname, ...@@ -390,13 +390,19 @@ buildDefaultACLCommands(const char *type, const char *nspname,
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n"); appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
if (!buildACLCommands("", NULL, type, initacls, initracls, owner, if (!buildACLCommands("", NULL, type, initacls, initracls, owner,
prefix->data, remoteVersion, sql)) prefix->data, remoteVersion, sql))
{
destroyPQExpBuffer(prefix);
return false; return false;
}
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n"); appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
} }
if (!buildACLCommands("", NULL, type, acls, racls, owner, if (!buildACLCommands("", NULL, type, acls, racls, owner,
prefix->data, remoteVersion, sql)) prefix->data, remoteVersion, sql))
{
destroyPQExpBuffer(prefix);
return false; return false;
}
destroyPQExpBuffer(prefix); destroyPQExpBuffer(prefix);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment