diff --git a/NEWS b/NEWS
index ad6b617614a23f38bdc841c604dc02d7fbfd233d..9fcd494bf100163ec3cf9363ac088b4a543a22dd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
 This file describes changes in recent versions of SLURM. It primarily
 documents those changes that are of interest to users and admins.
 
+* Changes in SLURM 1.4.0-pre10
+==============================
+ -- Critical bug fix in task/affinity when the CoresPerSocket is greater
+    than the ThreadsPerCore (invalid memory reference).
+
 * Changes in SLURM 1.4.0-pre9
 =============================
  -- OpenMPI users only: Add srun logic to automatically recreate and 
diff --git a/src/plugins/task/affinity/dist_tasks.c b/src/plugins/task/affinity/dist_tasks.c
index cbb27a877625050525e5c5300e134a96f82b1fe0..80931304ae9c60354ccebc028f6146e4d48ab63f 100644
--- a/src/plugins/task/affinity/dist_tasks.c
+++ b/src/plugins/task/affinity/dist_tasks.c
@@ -483,7 +483,7 @@ static char *_alloc_mask(launch_tasks_request_msg_t *req,
 	i = mask = 0;
 	for (s=0, s_miss=false; s<sockets; s++) {
 		for (c=0, c_hit=c_miss=false; c<cores; c++) {
-			for (t=0, t_hit=t_miss=false; t<cores; t++) {
+			for (t=0, t_hit=t_miss=false; t<threads; t++) {
 				if (bit_test(alloc_bitmap, i)) {
 					mask |= (1 << i);
 					(*whole_thread_cnt)++;