aboutsummaryrefslogtreecommitdiff
path: root/src/proto/proto.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/proto/proto.zig')
-rw-r--r--src/proto/proto.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/proto/proto.zig b/src/proto/proto.zig
index 5e4489d..9025347 100644
--- a/src/proto/proto.zig
+++ b/src/proto/proto.zig
@@ -51,13 +51,13 @@ pub fn read_message(allocator: std.mem.Allocator, stream_reader: anytype) !Backe
const tag = try stream_reader.readByte();
const len = try stream_reader.readIntBig(u32);
const buf = try allocator.alloc(u8, @as(u32, @intCast(len - 4)));
- defer allocator.free(buf);
try stream_reader.readNoEof(buf);
inline for (@typeInfo(BackendMessage).Union.fields) |field| {
if (field.type.Tag == tag) {
return @unionInit(BackendMessage, field.name, try field.type.read(allocator, buf));
}
} else {
+ allocator.free(buf);
return ProtocolError.InvalidMessageType;
}
}