summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2026-01-02 20:04:55 +0000
committerRobby Zambito <contact@robbyzambito.me>2026-01-02 20:28:26 +0000
commit9e9f7e8e50fb34ccdf19617b608e2fdf6c782a31 (patch)
tree75efd9b036b31381e00611694123429d4313b656
parent5f24108014cbf9048eaba862af5aaf2fa09be8e9 (diff)
Fix connect parsing
-rw-r--r--src/server/message_parser.zig8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/server/message_parser.zig b/src/server/message_parser.zig
index 600741d..c91836e 100644
--- a/src/server/message_parser.zig
+++ b/src/server/message_parser.zig
@@ -270,7 +270,7 @@ pub const Message = union(MessageType) {
// for storing the json string
var connect_string_writer_allocating: std.Io.Writer.Allocating = .init(alloc);
defer connect_string_writer_allocating.deinit();
- var connect_string_writer = connect_string_writer_allocating.writer;
+ var connect_string_writer = &connect_string_writer_allocating.writer;
// for parsing the json string
var connect_arena_allocator: std.heap.ArenaAllocator = .init(alloc);
@@ -280,15 +280,17 @@ pub const Message = union(MessageType) {
try in.discardAll(1); // throw away space
// Should read the next JSON object to the fixed buffer writer.
- _ = try in.streamDelimiter(&connect_string_writer, '}');
+ _ = try in.streamDelimiter(connect_string_writer, '}');
try connect_string_writer.writeByte('}');
try expectStreamBytes(in, "}\r\n"); // discard '}\r\n'
+ const connect_str = try connect_string_writer_allocating.toOwnedSlice();
+ defer alloc.free(connect_str);
// TODO: should be CONNECTION allocator
const res = try std.json.parseFromSliceLeaky(
Connect,
connect_allocator,
- connect_string_writer.buffered(),
+ connect_str,
.{ .allocate = .alloc_always },
);