ubusd: fix sending remove-object notification
authorFelix Fietkau <nbd@nbd.name>
Tue, 23 Aug 2016 10:55:08 +0000 (12:55 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 23 Aug 2016 10:55:09 +0000 (12:55 +0200)
Patch by Delio Brignoli <brignoli.delio@gmail.com>

Both ubusd_free_object (eventually via ubusd_create_object_event_msg)
and ubus_proto_send_msg_from_blob() use the same message buffer.
So ubusd_handle_remove_object builds the payload which gets (indirectly)
overwritten by the call to ubusd_free_object and then sent again by
ubus_proto_send_msg_from_blob.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
ubusd_proto.c

index 0624574925603a1cd7b265e33d42aef88774b9b3..53e507ad22b393ff31a547341fa0840317c88852 100644 (file)
@@ -130,8 +130,8 @@ static int ubusd_handle_remove_object(struct ubus_client *cl, struct ubus_msg_bu
        if (obj->type && obj->type->refcount == 1)
                blob_put_int32(&b, UBUS_ATTR_OBJTYPE, obj->type->id.id);
 
-       ubusd_free_object(obj);
        ubus_proto_send_msg_from_blob(cl, ub, UBUS_MSG_DATA);
+       ubusd_free_object(obj);
 
        return 0;
 }