CMakeLists.txt: bump minimum cmake version
[project/ubus.git] / ubusd_event.c
index d36bcb73dddaaf9eeb172c8d349c5d7de2442f84..15932a9f4535a110d89962cc5dc7b54face60382 100644 (file)
@@ -35,10 +35,9 @@ static void ubusd_delete_event_source(struct event_source *evs)
 
 void ubusd_event_cleanup_object(struct ubus_object *obj)
 {
-       struct event_source *ev;
+       struct event_source *ev, *tmp;
 
-       while (!list_empty(&obj->events)) {
-               ev = list_first_entry(&obj->events, struct event_source, list);
+       list_for_each_entry_safe(ev, tmp, &obj->events, list) {
                ubusd_delete_event_source(ev);
        }
 }
@@ -64,6 +63,9 @@ static int ubusd_alloc_event_pattern(struct ubus_client *cl, struct blob_attr *m
        bool partial = false;
        int len;
 
+       if (!msg)
+               return UBUS_STATUS_INVALID_ARGUMENT;
+
        blobmsg_parse(evr_policy, EVREG_LAST, attr, blob_data(msg), blob_len(msg));
        if (!attr[EVREG_OBJECT] || !attr[EVREG_PATTERN])
                return UBUS_STATUS_INVALID_ARGUMENT;
@@ -210,6 +212,9 @@ static int ubusd_forward_event(struct ubus_client *cl, struct blob_attr *msg)
        struct blob_attr *attr[EVMSG_LAST];
        const char *id;
 
+       if (!msg)
+               return UBUS_STATUS_INVALID_ARGUMENT;
+
        blobmsg_parse(ev_policy, EVMSG_LAST, attr, blob_data(msg), blob_len(msg));
        if (!attr[EVMSG_ID] || !attr[EVMSG_DATA])
                return UBUS_STATUS_INVALID_ARGUMENT;