workaround possibly false positive uses of memory after it is freed
[oweals/ubus.git] / ubusd_obj.c
index 0c9cb9ae820815da7597a40ec6e803aaad2e9c2b..dd44882e08d57e44ea983a1fdbbed58897204757 100644 (file)
@@ -20,13 +20,12 @@ struct avl_tree path;
 
 static void ubus_unref_object_type(struct ubus_object_type *type)
 {
-       struct ubus_method *m;
+       struct ubus_method *m, *tmp;
 
        if (--type->refcount > 0)
                return;
 
-       while (!list_empty(&type->methods)) {
-               m = list_first_entry(&type->methods, struct ubus_method, list);
+       list_for_each_entry_safe(m, tmp, &type->methods, list) {
                list_del(&m->list);
                free(m);
        }