From 97be0e87c3b6cd1d0717e00f85646f11a6730934 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 13 Apr 2016 16:03:33 -0500 Subject: [PATCH] scan: Fix crash Sometimes the periodic scan is started and stopped before the timeout was created. If periodic_scan_stop was called before, the timeout object was not reset to NULL, which can lead to a crash. --- src/scan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scan.c b/src/scan.c index f83cc058..8736b9a8 100644 --- a/src/scan.c +++ b/src/scan.c @@ -487,7 +487,11 @@ bool scan_periodic_stop(uint32_t ifindex) l_debug("Stopping periodic scan for ifindex: %u", ifindex); - l_timeout_remove(sc->sp.timeout); + if (sc->sp.timeout) { + l_timeout_remove(sc->sp.timeout); + sc->sp.timeout = NULL; + } + sc->sp.interval = 0; sc->sp.callback = NULL; sc->sp.userdata = NULL;