mirror of
https://git.robbyzambito.me/zaprus
synced 2025-12-20 08:14:50 +00:00
fix use after free
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user