From a14fa84693659c4c4a17204406945b29fae3d9c4 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue, 13 Mar 2012 13:28:11 -0400
Subject: [PATCH] Fix minor memory leak in PLy_typeinfo_dealloc().
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We forgot to free the per-attribute array element descriptors.

Jan Urbański
---
 src/pl/plpython/plpy_typeio.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c
index 1cc9b1e210e..d04fe46d4b7 100644
--- a/src/pl/plpython/plpy_typeio.c
+++ b/src/pl/plpython/plpy_typeio.c
@@ -74,8 +74,20 @@ PLy_typeinfo_dealloc(PLyTypeInfo *arg)
 {
 	if (arg->is_rowtype == 1)
 	{
+		int			i;
+
+		for (i = 0; i < arg->in.r.natts; i++)
+		{
+			if (arg->in.r.atts[i].elm != NULL)
+				PLy_free(arg->in.r.atts[i].elm);
+		}
 		if (arg->in.r.atts)
 			PLy_free(arg->in.r.atts);
+		for (i = 0; i < arg->out.r.natts; i++)
+		{
+			if (arg->out.r.atts[i].elm != NULL)
+				PLy_free(arg->out.r.atts[i].elm);
+		}
 		if (arg->out.r.atts)
 			PLy_free(arg->out.r.atts);
 	}
-- 
GitLab