From d690814b161ad6f005a551c6004d0fe13feb4949 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 28 Apr 2024 12:23:08 -0700 Subject: [PATCH] Core: fix potential printTitle leak Signed-off-by: Stephen Gutekanst --- src/Core.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Core.zig b/src/Core.zig index a3013ef1..35f6a161 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -66,6 +66,11 @@ pub fn printTitle( comptime fmt: []const u8, args: anytype, ) !void { + // Free any previous window title slice + // TODO: reuse allocations + if (core.get(window_id, .title)) |slice| core.state().allocator.free(slice); + + // Allocate and assign a new window title slice. const slice = try std.fmt.allocPrintZ(core.state().allocator, fmt, args); try core.set(window_id, .title, slice); }