Resource leak in pg_dump.c caused by transforms

Started by Michael Paquierover 10 years ago2 messages
#1Michael Paquier
michael.paquier@gmail.com
1 attachment(s)

Hi all,

Coverity is complaining that getTransforms in pg_dump.c leaks a
PQExpBuffer allocation.
Please find attached a patch to fix the leak.
Regards,
--
Michael

Attachments:

20150504_pgdump_transform_leak.patchtext/x-diff; charset=US-ASCII; name=20150504_pgdump_transform_leak.patchDownload
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 977b72e..dccb472 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -6596,7 +6596,7 @@ getTransforms(Archive *fout, int *numTransforms)
 	PGresult   *res;
 	int			ntups;
 	int			i;
-	PQExpBuffer query = createPQExpBuffer();
+	PQExpBuffer query;
 	TransformInfo   *transforminfo;
 	int			i_tableoid;
 	int			i_oid;
@@ -6612,6 +6612,8 @@ getTransforms(Archive *fout, int *numTransforms)
 		return NULL;
 	}
 
+	query = createPQExpBuffer();
+
 	/* Make sure we are in proper schema */
 	selectSourceSchema(fout, "pg_catalog");
 
#2Magnus Hagander
magnus@hagander.net
In reply to: Michael Paquier (#1)
Re: Resource leak in pg_dump.c caused by transforms

On Mon, May 4, 2015 at 6:34 AM, Michael Paquier <michael.paquier@gmail.com>
wrote:

Hi all,

Coverity is complaining that getTransforms in pg_dump.c leaks a
PQExpBuffer allocation.
Please find attached a patch to fix the leak.

Applied, thanks.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/