From a09a0fd1a06714bae8d2febe2b637b6ed46cde1f Mon Sep 17 00:00:00 2001
From: "Hon Ching(Vicky) Lo" <honclo@linux.vnet.ibm.com>
Date: Wed, 7 Sep 2016 21:57:17 -0400
Subject: [PATCH 22/28] [PATCH] Fix memory leak in Tspi_Context_Connect

Should (wszDestination != NULL) and (RPC_OpenContext OR
obj_context_set_machine_name) fail, machine_name is leaked.

Signed-off-by: Chads <cjschr@users.sourceforge.net>
Reviewed-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>

From https://sourceforge.net/p/trousers/trousers/ci/a09a0fd1a06714bae8d2febe2b637b6ed46cde1f
---
 src/tspi/tspi_context.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/tspi/tspi_context.c b/src/tspi/tspi_context.c
index 6c6ad56..93ce3ed 100644
--- a/src/tspi/tspi_context.c
+++ b/src/tspi/tspi_context.c
@@ -89,9 +89,11 @@ Tspi_Context_Connect(TSS_HCONTEXT tspContext,	/* in */
 		}
 
 		if ((result = RPC_OpenContext(tspContext, machine_name,
-					      CONNECTION_TYPE_TCP_PERSISTANT)))
+					      CONNECTION_TYPE_TCP_PERSISTANT))) {
+			free(machine_name);
 			return result;
-
+		}
+		free(machine_name);
 		if ((result = obj_context_set_machine_name(tspContext, machine_name,
 						strlen((char *)machine_name)+1)))
 			return result;
-- 
1.8.3.1

