From 0226d8780b3886a4acdd2d4c9731419306d470f6 Mon Sep 17 00:00:00 2001
From: Lukasz Majewski <l.majewski@majess.pl>
Date: Mon, 14 Sep 2015 00:57:04 +0200
Subject: [PATCH] env: import: hashtable: Free memory allocated before exiting
 from himport_r()

ithout this patch memory is not released on early exit.

Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
---
 lib/hashtable.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/hashtable.c b/lib/hashtable.c
index 7df424ad87..02b41050a4 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -842,8 +842,10 @@ int himport_r(struct hsearch_data *htab,
 		}
 	}
 
-	if(!size)
+	if (!size) {
+		free(data);
 		return 1;		/* everything OK */
+	}
 	if(crlf_is_lf) {
 		/* Remove Carriage Returns in front of Line Feeds */
 		unsigned ignored_crs = 0;
@@ -907,6 +909,7 @@ int himport_r(struct hsearch_data *htab,
 		if (*name == 0) {
 			debug("INSERT: unable to use an empty key\n");
 			__set_errno(EINVAL);
+			free(data);
 			return 0;
 		}
 
-- 
2.39.5