Core: fix potential printTitle leak
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
136c86e929
commit
d690814b16
1 changed files with 5 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue