mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +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.
|
/// Deep copy of the struct. Required by Config.
|
||||||
pub fn clone(self: *const Self, alloc: Allocator) Allocator.Error!Self {
|
pub fn clone(self: *const Self, alloc: Allocator) Allocator.Error!Self {
|
||||||
// Copy the list and all the strings in the list.
|
// Copy the list and all the strings in the list.
|
||||||
const list = try self.list.clone(alloc);
|
var list = try std.ArrayListUnmanaged([:0]const u8).initCapacity(
|
||||||
for (list.items) |*item| {
|
alloc,
|
||||||
const copy = try alloc.dupeZ(u8, item.*);
|
self.list.items.len,
|
||||||
item.* = copy;
|
);
|
||||||
|
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 };
|
return .{ .list = list };
|
||||||
|
@ -379,7 +379,7 @@ pub const DerivedConfig = struct {
|
|||||||
const custom_shaders = try config.@"custom-shader".clone(alloc);
|
const custom_shaders = try config.@"custom-shader".clone(alloc);
|
||||||
|
|
||||||
// Copy our font features
|
// 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
|
// Get our font styles
|
||||||
var font_styles = font.CodepointResolver.StyleStatus.initFill(true);
|
var font_styles = font.CodepointResolver.StyleStatus.initFill(true);
|
||||||
@ -398,7 +398,7 @@ pub const DerivedConfig = struct {
|
|||||||
return .{
|
return .{
|
||||||
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
||||||
.font_thicken = config.@"font-thicken",
|
.font_thicken = config.@"font-thicken",
|
||||||
.font_features = font_features,
|
.font_features = font_features.list,
|
||||||
.font_styles = font_styles,
|
.font_styles = font_styles,
|
||||||
|
|
||||||
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
.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);
|
const custom_shaders = try config.@"custom-shader".clone(alloc);
|
||||||
|
|
||||||
// Copy our font features
|
// 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
|
// Get our font styles
|
||||||
var font_styles = font.CodepointResolver.StyleStatus.initFill(true);
|
var font_styles = font.CodepointResolver.StyleStatus.initFill(true);
|
||||||
@ -309,7 +309,7 @@ pub const DerivedConfig = struct {
|
|||||||
return .{
|
return .{
|
||||||
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
.background_opacity = @max(0, @min(1, config.@"background-opacity")),
|
||||||
.font_thicken = config.@"font-thicken",
|
.font_thicken = config.@"font-thicken",
|
||||||
.font_features = font_features,
|
.font_features = font_features.list,
|
||||||
.font_styles = font_styles,
|
.font_styles = font_styles,
|
||||||
|
|
||||||
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
.cursor_color = if (!cursor_invert and config.@"cursor-color" != null)
|
||||||
|
Reference in New Issue
Block a user