tests: context: Verify for out of bounds array

The for loop could exit with a out of bounds (variable j) value for
the delayed_threads array, we verify for the variable value before
operating on the array

This issue was reported by Coverity

Coverity-CID: 160078

Change-Id: I6aa1cc325cc363be48cd72b2a58d0a55ec3854bc
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
This commit is contained in:
Sergio Rodriguez 2017-01-26 11:18:32 -08:00 committed by Anas Nashif
commit fdf9238382

View file

@ -784,9 +784,12 @@ static int test_timeout(void)
break;
}
}
k_thread_cancel(delayed_threads[j]);
++next_cancellation;
continue;
if (j < NUM_TIMEOUT_THREADS) {
k_thread_cancel(delayed_threads[j]);
++next_cancellation;
continue;
}
}
data = k_fifo_get(&timeout_order_fifo, 2750);