mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +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
|
||||
/// is idempotent but will waste memory if called multiple times.
|
||||
pub fn finalize(self: *Config) !void {
|
||||
const alloc = self._arena.?.allocator();
|
||||
|
||||
// We always load the theme first because it may set other fields
|
||||
// in our config.
|
||||
if (self.theme) |theme| {
|
||||
try self.loadTheme(theme);
|
||||
|
||||
// If we have different light vs dark mode themes, disable
|
||||
// window-theme = auto since that breaks it.
|
||||
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.
|
||||
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
|
||||
// the others to the font family. This way, if someone does
|
||||
// --font-family=foo, then we try to get the stylized versions of
|
||||
|
Reference in New Issue
Block a user