Commit c8739d6953

Andrew Kelley <andrew@ziglang.org>
2025-10-28 00:59:31
std.Io.Group: fix leak when wait is canceled
Only when the operation succeeds should the token field be set to null.
1 parent 3de1b6c
Changed files (1)
lib
std
lib/std/Io.zig
@@ -1040,11 +1040,14 @@ pub const Group = struct {
 
     /// Blocks until all tasks of the group finish.
     ///
-    /// Idempotent. Not threadsafe.
+    /// On success, further calls to `wait`, `waitUncancelable`, and `cancel`
+    /// do nothing.
+    ///
+    /// Not threadsafe.
     pub fn wait(g: *Group, io: Io) Cancelable!void {
         const token = g.token orelse return;
+        try io.vtable.groupWait(io.userdata, g, token);
         g.token = null;
-        return io.vtable.groupWait(io.userdata, g, token);
     }
 
     /// Equivalent to `wait` except uninterruptible.