szn

Bug 110 — client/client.zig — Heap-allocated body in recvPacket has no guaranteed free

110. client/client.zig — Heap-allocated body in recvPacket has no guaranteed free

File: src/client/client.zig:75–91 Severity: HIGH Status: ✅ FIXED — Packet now has is_owned field and deinit() method. recvPacket sets is_owned = true. Caller frees with reply.deinit(allocator).

const body = try self.allocator.alloc(u8, body_len);
// ...
return protocol.Packet{
    .msg_type = hdr[4],
    .data = body,
};

recvPacket allocates body and returns it inside a Packet value. There is no corresponding freePacket method, no documentation that the caller must free, and Packet.data is []const u8 — the caller has no way to know this slice was heap-allocated and must be freed. Every call to recvPacket that doesn’t explicitly free packet.data leaks memory.