From b53b67ecad1e02b156514b36bb2bfa47b4382bfd Mon Sep 17 00:00:00 2001 From: Jeremy Brodt Date: Thu, 26 Feb 2015 08:50:09 -0600 Subject: [PATCH] Issue #934: Handled condition when head is NULL. --- libraries/mbed/common/us_ticker_api.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libraries/mbed/common/us_ticker_api.c b/libraries/mbed/common/us_ticker_api.c index f98b56a9e8..f464da1095 100644 --- a/libraries/mbed/common/us_ticker_api.c +++ b/libraries/mbed/common/us_ticker_api.c @@ -118,5 +118,16 @@ void us_ticker_remove_event(ticker_event_t *obj) { } timestamp_t us_ticker_get_next_timestamp(void) { - return head->timestamp; + __disable_irq(); + + if (head == NULL) { + __enable_irq(); + return 0; + } + + timestamp_t next_timestamp = head->timestamp; + + __enable_irq(); + + return next_timestamp; }