From 62bcb951b8dc3d88ccb8df18bd7f5ef94d18bedc Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 21 Oct 2023 11:22:44 -0700 Subject: [PATCH] block: only free the descriptor once --- src/block.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/block.zig b/src/block.zig index 8126700..95576f4 100644 --- a/src/block.zig +++ b/src/block.zig @@ -107,10 +107,12 @@ pub fn Block( fn descDisposeHelper(src: *anyopaque) callconv(.C) void { const real_src: *Context = @ptrCast(@alignCast(src)); inline for (captures_info.fields) |field| { - if (field.type == objc.c.id) _Block_object_dispose(@field(real_src, field.name), 3); - alloc.free(std.mem.sliceTo(@field(@field(real_src, "descriptor"), "signature").?, 0)); - alloc.destroy(@field(real_src, "descriptor")); + if (field.type == objc.c.id) { + _Block_object_dispose(@field(real_src, field.name), 3); + } } + alloc.free(std.mem.sliceTo(real_src.descriptor.signature.?, 0)); + alloc.destroy(real_src.descriptor); } /// Creates a function type for the invocation function, but alters