libubus: Check if remove callback exists before call it
authorLukasz Baj <l.baj@radytek.com>
Thu, 29 Aug 2013 09:05:51 +0000 (11:05 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 29 Aug 2013 18:35:38 +0000 (20:35 +0200)
When process unsubscribes then remove callback is called. But it
can be NULL if not defined, so we should check it before we call it.

Signed-off-by: Lukasz Baj <l.baj@radytek.com>
libubus-obj.c

index ed18ca99f4ecff13bd0f16e82c859d870d580e66..bdb2e03478d70541691448ff7e2b672e0711871e 100644 (file)
@@ -27,7 +27,8 @@ ubus_process_unsubscribe(struct ubus_context *ctx, struct ubus_msghdr *hdr,
                return;
 
        s = container_of(obj, struct ubus_subscriber, obj);
-       s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET]));
+       if (s->remove_cb)
+               s->remove_cb(ctx, s, blob_get_u32(attrbuf[UBUS_ATTR_TARGET]));
 }
 
 static void