From 7d1d3dcb93db9a2a4018ee7065419a4fedf59d59 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Wed, 9 Sep 2015 16:39:17 -0700
Subject: [PATCH] Fix memory leak in commit 6bfe4eea66 by setting up the
 structure correctly.

---
 src/plugins/slurmctld/nonstop/read_config.c | 3 ++-
 src/slurmctld/reservation.c                 | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/plugins/slurmctld/nonstop/read_config.c b/src/plugins/slurmctld/nonstop/read_config.c
index 22e09990240..0c416597b3a 100644
--- a/src/plugins/slurmctld/nonstop/read_config.c
+++ b/src/plugins/slurmctld/nonstop/read_config.c
@@ -365,7 +365,7 @@ extern void create_hot_spare_resv(void)
 						  RESERVE_FLAG_IGN_JOBS;
 			resv_msg.name		= resv_name;
 			resv_msg.node_cnt	= node_cnt;
-			resv_msg.partition	= part_ptr->name;
+			resv_msg.partition	= xstrdup(part_ptr->name);
 			resv_msg.start_time	= now;
 			resv_msg.users		= xstrdup("root");
 			if (find_resv_name(resv_name)) {
@@ -377,6 +377,7 @@ extern void create_hot_spare_resv(void)
 				     resv_name);
 				(void) create_resv(&resv_msg);
 			}
+			xfree(resv_msg.partition);
 			xfree(resv_msg.users);
 			break;
 		}
diff --git a/src/slurmctld/reservation.c b/src/slurmctld/reservation.c
index a581b3304f3..06c8d45351d 100644
--- a/src/slurmctld/reservation.c
+++ b/src/slurmctld/reservation.c
@@ -2391,7 +2391,7 @@ extern int update_resv(resv_desc_msg_t *resv_desc_ptr)
 			goto update_failure;
 		}
 		xfree(resv_ptr->partition);
-		resv_ptr->partition	= xstrdup(resv_desc_ptr->partition);
+		resv_ptr->partition	= resv_desc_ptr->partition;
 		resv_desc_ptr->partition = NULL; /* Nothing left to free */
 		resv_ptr->part_ptr	= part_ptr;
 	}
-- 
GitLab