summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ham <bob.ham@tomltd.co.uk>2017-11-09 15:53:24 +0000
committerFelix Fietkau <nbd@nbd.name>2017-11-13 09:51:40 +0100
commit6d1ea6c33d321e4840b05986b6ce8e214bd1ba3a (patch)
tree635950be08933e4601e0369bb65546ecb5887116
parent9c13096b169759eabf4c528df22d605e2d6093f4 (diff)
downloadubus-6d1ea6c33d321e4840b05986b6ce8e214bd1ba3a.tar.gz
libubus: Fix deletion from context's object AVL tree when removing object
Objects are stored in the ubus context in an AVL tree. An AVL tree node contains a pointer to a key value. For the ubus context, this points to the id member of the object structure. In ubus_remove_object_cb, the id member is set to zero and then after, avl_delete is called and fails. To fix this, we call avl_delete before setting the object id to zero. Signed-off-by: Bob Ham <bob.ham@tomltd.co.uk>
-rw-r--r--libubus-obj.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libubus-obj.c b/libubus-obj.c
index a9972c5..9261b83 100644
--- a/libubus-obj.c
+++ b/libubus-obj.c
@@ -237,12 +237,12 @@ static void ubus_remove_object_cb(struct ubus_request *req, int type, struct blo
if (!attrbuf[UBUS_ATTR_OBJID])
return;
+ avl_delete(&req->ctx->objects, &obj->avl);
+
obj->id = 0;
if (attrbuf[UBUS_ATTR_OBJTYPE] && obj->type)
obj->type->id = 0;
-
- avl_delete(&req->ctx->objects, &obj->avl);
}
int ubus_remove_object(struct ubus_context *ctx, struct ubus_object *obj)