From 4550690fe3f2c44862f1e268c1f851adf753aad6 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Wed, 4 Dec 2024 03:03:13 -0800 Subject: Fix leak of cwcf_exceptions in FoldData Closes #20 --- src/FoldData.zig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/FoldData.zig') diff --git a/src/FoldData.zig b/src/FoldData.zig index d425178..a3d47af 100644 --- a/src/FoldData.zig +++ b/src/FoldData.zig @@ -47,6 +47,7 @@ pub fn init(allocator: mem.Allocator) !Self { self.cwcf_exceptions_max = @intCast(try reader.readInt(u24, endian)); len = try reader.readInt(u16, endian); self.cwcf_exceptions = try allocator.alloc(u21, len); + errdefer allocator.free(self.cwcf_exceptions); for (0..len) |i| self.cwcf_exceptions[i] = @intCast(try reader.readInt(u24, endian)); return self; @@ -56,6 +57,7 @@ pub fn deinit(self: *const Self) void { self.allocator.free(self.stage1); self.allocator.free(self.stage2); self.allocator.free(self.stage3); + self.allocator.free(self.cwcf_exceptions); } /// Returns the case fold for `cp`. -- cgit v1.2.3