properly NUL terminate ltsymbol

Although this is config error in config.h if the symbol is too long.
Make sure it is correct.

Note that the symbol would then get truncated.
This commit is contained in:
Hiltjo Posthuma committed 2026-10-16 13:26:00 +02:00
1 parent 3fdf0241fc
commit ce41d34791
1 file changed
+4 -2
+4 -2
View File
@@ -395,7 +395,8 @@ arrange(Monitor *m)
void
arrangemon(Monitor *m)
{
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol) - 1);
m->ltsymbol[sizeof(m->ltsymbol) - 1] = '\0';
if (m->lt[m->sellt]->arrange)
m->lt[m->sellt]->arrange(m);
}
@@ -645,7 +646,8 @@ createmon(void)
m->topbar = topbar;
m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
strncpy(m->ltsymbol, layouts[0].symbol, sizeof(m->ltsymbol) - 1);
m->ltsymbol[sizeof(m->ltsymbol) - 1] = '\0';
return m;
}