X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=libubus.c;h=8163ff7004fb6e23487a7661f9c55b8cc9a55783;hb=fd61773031402728098800c67f38f83ee04977ad;hp=bfbaeb6565905f2614e202fc8c25d265fd1ca52c;hpb=44a62711e0136a4a34f37d0b779c9c831818f9a4;p=project%2Fubus.git diff --git a/libubus.c b/libubus.c index bfbaeb6..8163ff7 100644 --- a/libubus.c +++ b/libubus.c @@ -294,6 +294,7 @@ int ubus_connect_ctx(struct ubus_context *ctx, const char *path) avl_init(&ctx->objects, ubus_cmp_id, false, NULL); if (ubus_reconnect(ctx, path)) { free(ctx->msgbuf.data); + ctx->msgbuf.data = NULL; return -1; } @@ -358,6 +359,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); }