mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
renderer/opengl: fix memory leak when copying font features
This commit is contained in:
@ -3478,10 +3478,17 @@ pub const RepeatableString = struct {
|
||||
/// Deep copy of the struct. Required by Config.
|
||||
pub fn clone(self: *const Self, alloc: Allocator) Allocator.Error!Self {
|
||||
// Copy the list and all the strings in the list.
|
||||
const list = try self.list.clone(alloc);
|
||||
for (list.items) |*item| {
|
||||
const copy = try alloc.dupeZ(u8, item.*);
|
||||
item.* = copy;
|
||||
var list = try std.ArrayListUnmanaged([:0]const u8).initCapacity(
|
||||
alloc,
|
||||
self.list.items.len,
|
||||
);
|
||||
errdefer {
|
||||
for (list.items) |item| alloc.free(item);
|
||||
list.deinit(alloc);
|
||||
}
|
||||
for (self.list.items) |item| {
|
||||
const copy = try alloc.dupeZ(u8, item);
|
||||
list.appendAssumeCapacity(copy);
|
||||
}
|
||||
|
||||
return .{ .list = list };
|
||||
|
@ -379,7 +379,7 @@ pub const DerivedConfig = struct {
|
||||
const custom_shaders = try config.@"custom-shader".clone(alloc);
|
||||
|
||||
// Copy our font features
|
||||
const font_features = try config.@"font-feature".list.clone(alloc);
|
||||
const font_features = try config.@"font-feature".clone(alloc);
|
||||
|
||||
// Get our font styles
|
||||
var font_styles = font.CodepointResolver.StyleStatus.initFill(true);
|
||||
@ -398,7 +398,7 @@ pub const DerivedConfig = struct {
|
||||
return .{
|
||||
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
||||
.font_thicken = config.@"font-thicken",
|
||||
.font_features = font_features,
|
||||
.font_features = font_features.list,
|
||||
.font_styles = font_styles,
|
||||
|
||||
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
||||
|
@ -290,7 +290,7 @@ pub const DerivedConfig = struct {
|
||||
const custom_shaders = try config.@"custom-shader".clone(alloc);
|
||||
|
||||
// Copy our font features
|
||||
const font_features = try config.@"font-feature".list.clone(alloc);
|
||||
const font_features = try config.@"font-feature".clone(alloc);
|
||||
|
||||
// Get our font styles
|
||||
var font_styles = font.CodepointResolver.StyleStatus.initFill(true);
|
||||
@ -309,7 +309,7 @@ pub const DerivedConfig = struct {
|
||||
return .{
|
||||
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
||||
.font_thicken = config.@"font-thicken",
|
||||
.font_features = font_features,
|
||||
.font_features = font_features.list,
|
||||
.font_styles = font_styles,
|
||||
|
||||
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
||||
|
Reference in New Issue
Block a user