From 11d696639705a1e57a1982d76c5964da4f41940c Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Thu, 17 Jul 2008 18:27:49 +0000
Subject: [PATCH] fix some other memory leaks in the mysql plugin

---
 src/common/slurm_accounting_storage.c            |  5 +++++
 .../mysql/accounting_storage_mysql.c             | 16 +++++++++++++---
 src/sacctmgr/file_functions.c                    |  5 +++--
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/common/slurm_accounting_storage.c b/src/common/slurm_accounting_storage.c
index 98b85f40735..1b2f586d1d6 100644
--- a/src/common/slurm_accounting_storage.c
+++ b/src/common/slurm_accounting_storage.c
@@ -338,6 +338,8 @@ extern void destroy_acct_user_rec(void *object)
 			list_destroy(acct_user->coord_accts);
 		xfree(acct_user->default_acct);
 		xfree(acct_user->name);
+		if(acct_user->qos_list)
+			list_destroy(acct_user->qos_list);
 		xfree(acct_user);
 	}
 }
@@ -355,6 +357,8 @@ extern void destroy_acct_account_rec(void *object)
 		xfree(acct_account->description);
 		xfree(acct_account->name);
 		xfree(acct_account->organization);
+		if(acct_account->qos_list)
+			list_destroy(acct_account->qos_list);
 		xfree(acct_account);
 	}
 }
@@ -425,6 +429,7 @@ extern void destroy_acct_qos_rec(void *object)
 {
 	acct_qos_rec_t *acct_qos = (acct_qos_rec_t *)object;
 	if(acct_qos) {
+		xfree(acct_qos->description);
 		xfree(acct_qos->name);
 		xfree(acct_qos);
 	}
diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
index a416876e492..c21d8ee5ec5 100644
--- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
+++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c
@@ -863,6 +863,8 @@ static int _remove_common(mysql_conn_t *mysql_conn,
 			   row2[1],
 			   assoc_table, row2[2],
 			   row2[1]);
+		
+		mysql_free_result(result2);
 
 		debug3("%d(%d) query\n%s",
 		       mysql_conn->conn, __LINE__, query);
@@ -1735,10 +1737,18 @@ extern int acct_storage_p_add_users(mysql_conn_t *mysql_conn, uint32_t uid,
 
 			xstrfmtcat(vals, ", '%s'", qos_val); 		
 			xstrfmtcat(extra, ", qos='%s'", qos_val); 		
-		} else {
-			xstrfmtcat(vals, ", 'normal'"); 		
-			xstrfmtcat(extra, ", qos='normal'"); 	       
 		}
+		/* Since I don't really want to go find out which id
+		 * normal is we are not going to add it at all which
+		 * isn't a big deal since if the list is blank the user
+		 * will get it be default 
+		 */
+		/* else { */
+/* 			/\* Add normal qos to the user *\/ */
+/* 			xstrcat(cols, ", qos"); */
+/* 			xstrfmtcat(vals, ", ',0'"); 		 */
+/* 			xstrfmtcat(extra, ", qos=',0'"); 	        */
+/* 		} */
 
 		if(object->admin_level != ACCT_ADMIN_NOTSET) {
 			xstrcat(cols, ", admin_level");
diff --git a/src/sacctmgr/file_functions.c b/src/sacctmgr/file_functions.c
index 79c9fa15584..c7ebd6af836 100644
--- a/src/sacctmgr/file_functions.c
+++ b/src/sacctmgr/file_functions.c
@@ -730,9 +730,10 @@ static int _mod_acct(sacctmgr_file_opts_t *file_opts,
 			       new_qos);
 			xfree(new_qos);
 			changed = 1;
-		} else 
+		} else {
 			list_destroy(mod_acct.qos_list);
-
+			mod_acct.qos_list = NULL;
+		}
 	} else if(file_opts->qos_list && list_count(file_opts->qos_list)) {
 		char *new_qos = get_qos_complete_str(qos_list,
 						     file_opts->qos_list);
-- 
GitLab