From e95331dd9facb2ebc39053da08e37812f29e83ba Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Thu, 5 Jul 2018 13:44:45 +0200
Subject: [PATCH] Make scheduler_reweight() robust against empty cells.

---
 src/scheduler.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/scheduler.c b/src/scheduler.c
index 63dd9ef923..127d073855 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -1191,9 +1191,9 @@ void scheduler_reweight(struct scheduler *s, int verbose) {
         t->weight = t->unlock_tasks[j]->weight;
     float cost = 0;
 
-    const float count_i = t->ci->count;
+    const float count_i = (t->ci != NULL) ? t->ci->count : 0.f;
     const float count_j = (t->cj != NULL) ? t->cj->count : 0.f;
-    const float gcount_i = t->ci->gcount;
+    const float gcount_i = (t->ci != NULL) ? t->ci->gcount : 0.f;
     const float gcount_j = (t->cj != NULL) ? t->cj->gcount : 0.f;
 
     switch (t->type) {
-- 
GitLab