diff --git a/sway/main.c b/sway/main.c index 1c4939aa0..d855de5b5 100644 --- a/sway/main.c +++ b/sway/main.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -30,6 +31,7 @@ static int exit_value = 0; static struct rlimit original_nofile_rlimit = {0}; struct sway_server server = {0}; struct sway_debug debug = {0}; +char **child_envp; void sway_terminate(int exit_code) { if (!server.wl_display) { @@ -348,6 +350,8 @@ int main(int argc, char **argv) { ipc_init(&server); setenv("WAYLAND_DISPLAY", server.socket, true); + // g_get_environ creates a newly-allocated environment buffer + child_envp = g_get_environ(); if (!load_main_config(config_path, false, false)) { sway_terminate(EXIT_FAILURE); goto shutdown; @@ -381,6 +385,7 @@ shutdown: free(config_path); free_config(config); + g_strfreev(child_envp); pango_cairo_font_map_set_default(NULL);