mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
Merge pull request #2768 from ghostty-org/push-pzzwlvwumwpq
config: fix invalid memory access on theme loading
This commit is contained in:
@ -2749,13 +2749,9 @@ fn loadTheme(self: *Config, theme: Theme) !void {
|
|||||||
/// Call this once after you are done setting configuration. This
|
/// Call this once after you are done setting configuration. This
|
||||||
/// is idempotent but will waste memory if called multiple times.
|
/// is idempotent but will waste memory if called multiple times.
|
||||||
pub fn finalize(self: *Config) !void {
|
pub fn finalize(self: *Config) !void {
|
||||||
const alloc = self._arena.?.allocator();
|
|
||||||
|
|
||||||
// We always load the theme first because it may set other fields
|
// We always load the theme first because it may set other fields
|
||||||
// in our config.
|
// in our config.
|
||||||
if (self.theme) |theme| {
|
if (self.theme) |theme| {
|
||||||
try self.loadTheme(theme);
|
|
||||||
|
|
||||||
// If we have different light vs dark mode themes, disable
|
// If we have different light vs dark mode themes, disable
|
||||||
// window-theme = auto since that breaks it.
|
// window-theme = auto since that breaks it.
|
||||||
if (!std.mem.eql(u8, theme.light, theme.dark)) {
|
if (!std.mem.eql(u8, theme.light, theme.dark)) {
|
||||||
@ -2763,8 +2759,14 @@ pub fn finalize(self: *Config) !void {
|
|||||||
// because it'll force the theme based on the Ghostty theme.
|
// because it'll force the theme based on the Ghostty theme.
|
||||||
if (self.@"window-theme" == .auto) self.@"window-theme" = .system;
|
if (self.@"window-theme" == .auto) self.@"window-theme" = .system;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warning: loadTheme will deinit our existing config and replace
|
||||||
|
// it so all memory from self prior to this point will be freed.
|
||||||
|
try self.loadTheme(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const alloc = self._arena.?.allocator();
|
||||||
|
|
||||||
// If we have a font-family set and don't set the others, default
|
// If we have a font-family set and don't set the others, default
|
||||||
// the others to the font family. This way, if someone does
|
// the others to the font family. This way, if someone does
|
||||||
// --font-family=foo, then we try to get the stylized versions of
|
// --font-family=foo, then we try to get the stylized versions of
|
||||||
|
Reference in New Issue
Block a user