Переглянути джерело

do not let possibility to go out of bounds

Terry Cojean 8 роки тому
батько
коміт
94e7f6c504
1 змінених файлів з 3 додано та 1 видалено
  1. 3 1
      examples/sched_ctx/nested_sched_ctxs.c

+ 3 - 1
examples/sched_ctx/nested_sched_ctxs.c

@@ -51,7 +51,9 @@ int parallel_code(int sched_ctx)
 static void sched_ctx_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg)
 {
 	unsigned sched_ctx = (uintptr_t)arg;
-	tasks_executed[sched_ctx-1]+= parallel_code(sched_ctx);
+	int t = parallel_code(sched_ctx);
+	if (sched_ctx > 0 && sched_ctx < 3)
+		tasks_executed[sched_ctx-1] += t;
 	//printf("w %d executed %d it \n", w, n);
 }