diff options
| author | Eyal Birger | 2016-05-15 05:13:27 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2016-05-15 07:39:24 +0000 |
| commit | 3b8d4b5653ef47bd2032d377cecfee40b613eb72 (patch) | |
| tree | 2a73bf8570eb9959b1112364c2774af22dba1832 | |
| parent | fcf5d8af65f41d6a106ad08d1df5de9729f5399a (diff) | |
| download | ubus-3b8d4b5653ef47bd2032d377cecfee40b613eb72.tar.gz | |
libubus: nullify stale msgbuf pointer in case of ubus_connect_ctx() failure
If the ubus_reconnect() call fails in ubus_connect_ctx(), the msgbuf.data
newly allocated buffer is freed, but its pointer in the ubus_context is not
removed.
This leads to a double free error if ubus_auto_shutdown() is called for cleanup
after ubus_auto_connect() failed to connect to ubusd.
Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
| -rw-r--r-- | libubus.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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; } |