From 2220e497bda8b274677e660fb5922cbb31487235 Mon Sep 17 00:00:00 2001 From: Guy McSwain Date: Fri, 18 Dec 2020 20:23:52 -0600 Subject: [PATCH] Fix issue#397 gpioSetTimerFunc NULL cancel error --- pigpio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pigpio.c b/pigpio.c index 9428b71..af94c11 100644 --- a/pigpio.c +++ b/pigpio.c @@ -12488,8 +12488,11 @@ int gpioSetTimerFunc(unsigned id, unsigned millis, gpioTimerFunc_t f) if (id > PI_MAX_TIMER) SOFT_ERROR(PI_BAD_TIMER, "bad timer id (%d)", id); - if ((millis < PI_MIN_MS) || (millis > PI_MAX_MS)) - SOFT_ERROR(PI_BAD_MS, "timer %d, bad millis (%d)", id, millis); + if (f) + { + if ((millis < PI_MIN_MS) || (millis > PI_MAX_MS)) + SOFT_ERROR(PI_BAD_MS, "timer %d, bad millis (%d)", id, millis); + } intGpioSetTimerFunc(id, millis, f, 0, NULL);