free freeing wrong amount in thread pool impl

This commit is contained in:
Andrew Kelley 2025-03-28 17:20:35 -07:00
parent 1493c3b5f3
commit 08bb7c6c88

View File

@ -396,6 +396,6 @@ pub fn @"await"(userdata: ?*anyopaque, any_future: *std.Io.AnyFuture, result: []
const closure: *AsyncClosure = @ptrCast(@alignCast(any_future));
closure.reset_event.wait();
const base: [*]align(@alignOf(AsyncClosure)) u8 = @ptrCast(closure);
@memcpy(result, (base + @sizeOf(AsyncClosure))[0..result.len]);
thread_pool.allocator.free(base[0 .. @sizeOf(AsyncClosure) + result.len]);
@memcpy(result, closure.resultPointer()[0..result.len]);
thread_pool.allocator.free(base[0 .. closure.result_offset + result.len]);
}