From 4a0a5f21fa05070295557ad6ac9b9bbe247938ad Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Wed, 14 Jan 2015 15:14:20 -0500
Subject: [PATCH] vacuumlo: Avoid unlikely memory leak.

Spotted by Coverity.  This isn't likely to matter in practice, but
there's no harm in fixing it.

Michael Paquier
---
 contrib/vacuumlo/vacuumlo.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/contrib/vacuumlo/vacuumlo.c b/contrib/vacuumlo/vacuumlo.c
index 43130dca8af..ca0d3048b82 100644
--- a/contrib/vacuumlo/vacuumlo.c
+++ b/contrib/vacuumlo/vacuumlo.c
@@ -240,6 +240,12 @@ vacuumlo(const char *database, const struct _param * param)
 			fprintf(stderr, "Out of memory\n");
 			PQclear(res);
 			PQfinish(conn);
+			if (schema != NULL)
+				PQfreemem(schema);
+			if (schema != NULL)
+				PQfreemem(table);
+			if (schema != NULL)
+				PQfreemem(field);
 			return -1;
 		}
 
@@ -256,6 +262,9 @@ vacuumlo(const char *database, const struct _param * param)
 			PQclear(res2);
 			PQclear(res);
 			PQfinish(conn);
+			PQfreemem(schema);
+			PQfreemem(table);
+			PQfreemem(field);
 			return -1;
 		}
 		PQclear(res2);
-- 
GitLab