mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 16:06:37 +01:00
Log empty value if envvar is not defined
If the environment variable is not defined, getenv returns NULL. Passing a NULL pointer to the "%s" format specifier is undefined behavior. Even if some implementations output "(null)", an empty string is nicer.
This commit is contained in:
parent
2960b2c9b6
commit
a1c6052383
1 changed files with 2 additions and 1 deletions
|
@ -138,7 +138,8 @@ static void log_env(void) {
|
|||
"SWAYSOCK",
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(log_vars) / sizeof(char *); ++i) {
|
||||
sway_log(SWAY_INFO, "%s=%s", log_vars[i], getenv(log_vars[i]));
|
||||
char *value = getenv(log_vars[i]);
|
||||
sway_log(SWAY_INFO, "%s=%s", log_vars[i], value != NULL ? value : "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue