File autofs-5-1-3-fix-possible-map-instance-memory-leak.patch of Package autofs.14028

From: Ian Kent <raven@themaw.net>
Subject: autofs-5.1.3 - fix possible map instance memory leak
Git-commit: b66deff4241ddc6de6bc67bc42bc2d47a5e35229
Patch-mainline: 5.1.4
References: bsc#1038198

When using a temporary map unconditionally updating the original map
instance pointer will lead to a memory leak when the instance pointer
is already set (among other problems).

Signed-off-by: Ian Kent <raven@themaw.net>
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
 daemon/lookup.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/daemon/lookup.c
+++ b/daemon/lookup.c
@@ -513,7 +513,8 @@ static enum nsswitch_status read_map_sou
 	result = read_file_source_instance(ap, &tmap, age);
 	pthread_cleanup_pop(1);
 
-	map->instance = tmap.instance;
+	if (!map->instance)
+		map->instance = tmap.instance;
 
 	return result;
 }
@@ -904,7 +905,8 @@ static enum nsswitch_status lookup_map_n
 
 	result = lookup_name_file_source_instance(ap, &tmap, name, name_len);
 
-	map->instance = tmap.instance;
+	if (!map->instance)
+		map->instance = tmap.instance;
 
 	/* path is freed in free_argv */
 	free_argv(tmap.argc, tmap.argv);
openSUSE Build Service is sponsored by