mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 19:54:48 +00:00
Fix double free
was freeing the wrong element before.
This commit is contained in:
@@ -133,7 +133,9 @@ fn handleConnectionInfallible(
|
||||
id: usize,
|
||||
stream: std.Io.net.Stream,
|
||||
) void {
|
||||
handleConnection(server, server_allocator, io, id, stream) catch {};
|
||||
handleConnection(server, server_allocator, io, id, stream) catch |err| {
|
||||
std.log.err("Failed processing client {d}: {any}", .{ id, err });
|
||||
};
|
||||
}
|
||||
|
||||
fn handleConnection(
|
||||
@@ -322,8 +324,9 @@ fn unsubscribe(server: *Server, io: std.Io, gpa: std.mem.Allocator, id: usize, m
|
||||
try server.subs_lock.lock(io);
|
||||
defer server.subs_lock.unlock(io);
|
||||
const len = server.subscriptions.items.len;
|
||||
for (0..len) |i| {
|
||||
const sub = server.subscriptions.items[len - i - 1];
|
||||
for (0..len) |from_end| {
|
||||
const i = len - from_end - 1;
|
||||
const sub = server.subscriptions.items[i];
|
||||
if (sub.client_id == id and std.mem.eql(u8, sub.sid, msg.sid)) {
|
||||
gpa.free(sub.sid);
|
||||
gpa.free(sub.subject);
|
||||
|
||||
Reference in New Issue
Block a user