diff --git a/NEWS b/NEWS
index 6f1bdcc3ff5d5fed7695d40bc6953b62fad9a0ed..87bfee1e066d9014428dff96f396f75586d9a37b 100644
--- a/NEWS
+++ b/NEWS
@@ -311,6 +311,7 @@ documents those changes that are of interest to users and admins.
  -- NRT - Fix issue with 1 node jobs.  It turns out the network does need to
     be setup for 1 node jobs.
  -- Fix recovery of job dependency on task of job array when slurmctld restarts.
+ -- mysql - Fix invalid memory reference.
 
 * Changes in Slurm 2.6.7
 ========================
diff --git a/src/plugins/accounting_storage/mysql/as_mysql_jobacct_process.c b/src/plugins/accounting_storage/mysql/as_mysql_jobacct_process.c
index 7229fce571683374749cdbf5c637d43319c41eb9..800d3ad81087425ce66b8661f09ea6c8f1202c64 100644
--- a/src/plugins/accounting_storage/mysql/as_mysql_jobacct_process.c
+++ b/src/plugins/accounting_storage/mysql/as_mysql_jobacct_process.c
@@ -922,7 +922,6 @@ extern List setup_cluster_list_with_inx(mysql_conn_t *mysql_conn,
 		mysql_free_result(result);
 		return NULL;
 	}
-	mysql_free_result(result);
 
 	/* On a Cray System when dealing with hostlists as we are here
 	   this always needs to be 1.
@@ -932,6 +931,8 @@ extern List setup_cluster_list_with_inx(mysql_conn_t *mysql_conn,
 	else
 		dims = atoi(row[0]);
 
+	mysql_free_result(result);
+
 	temp_hl = hostlist_create_dims(job_cond->used_nodes, dims);
 	if (hostlist_count(temp_hl) <= 0) {
 		error("we didn't get any real hosts to look for.");