diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-05-10 12:46:34 -0400 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-05-10 21:46:53 -0400 |
commit | 56e72928c6e9ea554870d9673b71d280bfb50e09 (patch) | |
tree | d3abe30ef17c3e11f84351ebf14f38a642a97837 /src | |
parent | a80c9abfe736abd2819cb109ee50818602cdac0e (diff) |
fix use after freepush-tznmzxxxnnoz
Diffstat (limited to 'src')
-rw-r--r-- | src/Client.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Client.zig b/src/Client.zig index af78d39..57af48c 100644 --- a/src/Client.zig +++ b/src/Client.zig @@ -85,7 +85,7 @@ pub fn sendInitialConnection(payload: []const u8, initial_port: u16, allocator: base64Enc.calcSize(payload.len), ), ); - defer allocator.free(msg_bytes); + const msg: *SaprusMessage = .init(.connection, msg_bytes); const connection = (try msg.getSaprusTypePayload()).connection; @@ -120,8 +120,9 @@ pub fn connect(payload: []const u8, allocator: Allocator) !?SaprusConnection { try sock.bind(bind_addr); const msg = try sendInitialConnection(payload, initial_port, allocator); + defer allocator.free(msg.asBytes()); - var response_buf: [4096]u8 align(4) = @splat(0); + var response_buf: [4096]u8 align(@alignOf(SaprusMessage)) = undefined; _ = try sock.receive(&response_buf); // Ignore message that I sent. const len = try sock.receive(&response_buf); |