fix segmenation fault in theme initialization

- initializes theme with conf->colors instead of NULL
- ensures conf->initial_color_theme is not out of range
This commit is contained in:
csskevin 2025-08-22 13:25:19 +02:00
parent 72d9a13c0c
commit e8dcfe8a3f
2 changed files with 8 additions and 4 deletions

View file

@ -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 {

View file

@ -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;