summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>2017-01-03 11:37:05 +0530
committerFelix Fietkau <nbd@nbd.name>2017-01-04 22:02:43 +0100
commitad5333a73b222e95458e05d52f349194df9ae7c6 (patch)
tree40d00e66fbbbc3ed00f008ca2f1963b92aa86293
parentd5fabacba1f701cab27bbee907d7c4a2ab74cb4d (diff)
downloadubus-ad5333a73b222e95458e05d52f349194df9ae7c6.tar.gz
ubus: ubus_free: clear pending timers before freeing context
If a synchronous operation is executed on a ubus context after uloop_done() has been called, the context's pending_timer may remain in uloop's list of timeouts. This leads to undefined behaviour during next execution of uloop code, as it may be referring to unavailable memory or memory that has been allocated for different purposes. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
-rw-r--r--libubus.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/libubus.c b/libubus.c
index b25d8b0..51a1483 100644
--- a/libubus.c
+++ b/libubus.c
@@ -362,6 +362,7 @@ void ubus_shutdown(struct ubus_context *ctx)
if (!ctx)
return;
close(ctx->sock.fd);
+ uloop_timeout_cancel(&ctx->pending_timer);
free(ctx->msgbuf.data);
}