Commit 6c0fa316 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Also check that the offset array is not overflowing.

parent a1fb04a8
......@@ -763,12 +763,18 @@ void scheduler_set_unlocks(struct scheduler *s) {
}
/* Compute the offset for each unlock block. */
short int *offsets;
if ((offsets = (short int *)malloc(sizeof(short int) * (s->nr_tasks + 1))) ==
NULL)
int *offsets;
if ((offsets = (int *)malloc(sizeof(int) * (s->nr_tasks + 1))) == NULL)
error("Failed to allocate temporary offsets array.");
offsets[0] = 0;
for (int k = 0; k < s->nr_tasks; k++) offsets[k + 1] = offsets[k] + counts[k];
for (int k = 0; k < s->nr_tasks; k++) {
offsets[k + 1] = offsets[k] + counts[k];
#ifdef SWIFT_DEBUG_CHECKS
/* Check that we are not overflowing */
if (offsets[k + 1] < 0) error("Task unlock offset array overflowing");
#endif
}
/* Create and fill a temporary array with the sorted unlocks. */
struct task **unlocks;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment