From e8dcfe8a3f9a0b2e611aaf05e8e0730a44c55210 Mon Sep 17 00:00:00 2001 From: csskevin Date: Fri, 22 Aug 2025 13:25:19 +0200 Subject: [PATCH] fix segmenation fault in theme initialization - initializes theme with conf->colors instead of NULL - ensures conf->initial_color_theme is not out of range --- config.c | 8 ++++++-- terminal.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 77dc3a73..ac7d6571 100644 --- a/config.c +++ b/config.c @@ -1107,8 +1107,12 @@ parse_section_main(struct context *ctx) sizeof(conf->initial_color_theme) == sizeof(int), "enum is not 32-bit"); - return value_to_enum(ctx, (const char*[]){"1", "2", NULL}, - (int *)&conf->initial_color_theme); + int initial_color_theme = conf->initial_color_theme; + bool status = value_to_enum(ctx, (const char*[]){"1", "2", NULL}, + (int *)&initial_color_theme); + if(initial_color_theme != -1) + conf->initial_color_theme = initial_color_theme; + return status; } else { diff --git a/terminal.c b/terminal.c index 2e23f749..d50806fe 100644 --- a/terminal.c +++ b/terminal.c @@ -1266,7 +1266,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper, ? wayl_do_linear_blending(wayl, conf) ? SHM_BITS_16 : SHM_BITS_8 : conf->tweak.surface_bit_depth; - const struct color_theme *theme = NULL; + const struct color_theme *theme = &conf->colors; switch (conf->initial_color_theme) { case COLOR_THEME1: theme = &conf->colors; break; case COLOR_THEME2: theme = &conf->colors2; break; @@ -2169,7 +2169,7 @@ term_reset(struct terminal *term, bool hard) if (!hard) return; - const struct color_theme *theme = NULL; + const struct color_theme *theme = &term->conf->colors; switch (term->conf->initial_color_theme) { case COLOR_THEME1: theme = &term->conf->colors; break;