From 0c7601bfd68d8ba6fa27e4dcca10559a659ced63 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 18 Oct 2021 14:13:18 +1100 Subject: [PATCH] Parameter checks --- quantum/deferred_exec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/quantum/deferred_exec.c b/quantum/deferred_exec.c index da2e2afa464c..081a3fa69600 100644 --- a/quantum/deferred_exec.c +++ b/quantum/deferred_exec.c @@ -21,7 +21,7 @@ static uint32_t last_deferred_exec_check = 0; static deferred_executor_t executors[MAX_DEFERRED_EXECUTORS] = {0}; deferred_token enqueue_deferred_exec(uint32_t delay_ms, deferred_exec_callback callback, void *cb_arg) { - // Ignore queueing if it's a zero-time delay + // Ignore queueing if it's a zero-time delay, or invalid callback if (delay_ms == 0 || !callback) { return INVALID_DEFERRED_TOKEN; } @@ -49,6 +49,11 @@ deferred_token enqueue_deferred_exec(uint32_t delay_ms, deferred_exec_callback c } bool extend_deferred_exec(deferred_token token, uint32_t delay_ms) { + // Ignore queueing if it's a zero-time delay + if (delay_ms == 0) { + return false; + } + for (int i = 0; i < MAX_DEFERRED_EXECUTORS; ++i) { deferred_executor_t *entry = &executors[i]; if (entry->token == (uint16_t)token) {