summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Ardelean <ardeleanalex@gmail.com>2015-12-17 10:45:22 +0200
committerFelix Fietkau <nbd@openwrt.org>2015-12-19 12:29:23 +0100
commit85e4de419362dcf831539d63c06a88015a582785 (patch)
tree41829ffa9f7157361d73c178d2a7ece3d1dede56
parent68da4ceb873e7bdd12e0b7256a433fe8fdcf3bb5 (diff)
downloadubus-85e4de419362dcf831539d63c06a88015a582785.tar.gz
libubus: add null for ubus_context object in ubus_shutdown()
At the moment, we do our own null checks before calling ubus_free(). The likely-hood of 'ctx' being null (in ubus_free()) is low, but since free() handles null, might make sense for ubus_free() to do so as well. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
-rw-r--r--libubus.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libubus.c b/libubus.c
index bfbaeb6..d52faff 100644
--- a/libubus.c
+++ b/libubus.c
@@ -358,6 +358,8 @@ struct ubus_context *ubus_connect(const char *path)
void ubus_shutdown(struct ubus_context *ctx)
{
blob_buf_free(&b);
+ if (!ctx)
+ return;
close(ctx->sock.fd);
free(ctx->msgbuf.data);
}