aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-01-10 15:41:03 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-01-10 15:41:03 +0000
commit208008d717567f1a3a096d5775356a67d8dd6517 (patch)
tree4bed52e1d289f7a2c6d4bedf9d42143e4641aa3a
parentwayland: surface_scale_explicit_width_height(): dont assert width/height are valid for scale, take 2 (diff)
config: fix cloning of env_vars tllist
When cloning a config struct, the env_vars tllist wasn't correctly copied. We did correctly iterate and duplicate all old entries, but we did *not* reset the list in the cloned struct before doing so. This meant the list contained entries shared with the original list, causing double free:s in --server mode.
-rw-r--r--CHANGELOG.md2
-rw-r--r--config.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c4f998d..d7f41bb5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -80,6 +80,8 @@
* Crash when using a desktop scaling factor > 1, on compositors that
implements neither the `fractional-scale-v1`, nor the
`cursor-shape-v1` Wayland protocols ([#1573][1573]).
+* Crash in `--server` mode when one or more environment variables are
+ set in `[environment]`.
[1531]: https://codeberg.org/dnkl/foot/issues/1531
[1573]: https://codeberg.org/dnkl/foot/issues/1573
diff --git a/config.c b/config.c
index e5cd6723..de15add3 100644
--- a/config.c
+++ b/config.c
@@ -3393,6 +3393,8 @@ config_clone(const struct config *old)
key_binding_list_clone(&conf->bindings.url, &old->bindings.url);
key_binding_list_clone(&conf->bindings.mouse, &old->bindings.mouse);
+ conf->env_vars.length = 0;
+ conf->env_vars.head = conf->env_vars.tail = NULL;
tll_foreach(old->env_vars, it) {
struct env_var copy = {
.name = xstrdup(it->item.name),