diff --git a/NEWS b/NEWS
index 7b1eaf6edfa7c106fbdabf0578cd473eb3340173..05c6eadfef27ecf5b88bd50a5ab8da4f9a3edece 100644
--- a/NEWS
+++ b/NEWS
@@ -73,6 +73,7 @@ documents those changes that are of interest to users and administrators.
  -- Fix parsing in regression test1.92 for some prompts.
  -- sbcast - use slurmd's gid cache rather than a separate lookup.
  -- slurmd - return error if setgroups() call fails in _drop_privileges().
+ -- Fix possible memory corruption if a job is using GRES and changing size.
 
 * Changes in Slurm 16.05.6
 ==========================
diff --git a/src/common/gres.c b/src/common/gres.c
index daf1ab2226708640ff7dae617446014bb08810f5..18d4177cedacace7b278993853ea0801946a7dc4 100644
--- a/src/common/gres.c
+++ b/src/common/gres.c
@@ -4185,7 +4185,7 @@ static int _job_alloc(void *job_gres_data, void *node_gres_data,
 	}
 
 	if (!node_offset && job_gres_ptr->gres_cnt_step_alloc) {
-		uint64_t *tmp = xmalloc(sizeof(uint64_t) * job_gres_ptr->node_cnt);
+		uint64_t *tmp = xmalloc(sizeof(uint64_t) * node_cnt);
 		memcpy(tmp, job_gres_ptr->gres_cnt_step_alloc,
 		       sizeof(uint64_t) * MIN(node_cnt,
 					      job_gres_ptr->node_cnt));
@@ -4194,7 +4194,7 @@ static int _job_alloc(void *job_gres_data, void *node_gres_data,
 	}
 	if (job_gres_ptr->gres_cnt_step_alloc == NULL) {
 		job_gres_ptr->gres_cnt_step_alloc =
-			xmalloc(sizeof(uint64_t) * job_gres_ptr->node_cnt);
+			xmalloc(sizeof(uint64_t) * node_cnt);
 	}
 
 	/*