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>
This commit is contained in:
Alexandru Ardelean 2015-12-17 10:45:22 +02:00 committed by Felix Fietkau
parent 68da4ceb87
commit 85e4de4193

View file

@ -358,6 +358,8 @@ struct ubus_context *ubus_connect(const char *path)
void ubus_shutdown(struct ubus_context *ctx) void ubus_shutdown(struct ubus_context *ctx)
{ {
blob_buf_free(&b); blob_buf_free(&b);
if (!ctx)
return;
close(ctx->sock.fd); close(ctx->sock.fd);
free(ctx->msgbuf.data); free(ctx->msgbuf.data);
} }