workaround possibly false positive uses of memory after it is freed
[oweals/ubus.git] / ubusd_proto.c
index 2d04b5a7da6e83e73580a39ed9043b1e9dfe79ed..4dd89ddb4939d6acb706fbbea1467a9e56d6c1f4 100644 (file)
@@ -519,12 +519,12 @@ free:
 
 void ubusd_proto_free_client(struct ubus_client *cl)
 {
-       struct ubus_object *obj;
+       struct ubus_object *obj, *tmp;
 
-       while (!list_empty(&cl->objects)) {
-               obj = list_first_entry(&cl->objects, struct ubus_object, list);
+       list_for_each_entry_safe(obj, tmp, &cl->objects, list) {
                ubusd_free_object(obj);
        }
+
        ubus_msg_free(cl->retmsg);
        blob_buf_free(&cl->b);