mirror of
https://git.zx2c4.com/cgit
synced 2024-11-22 08:28:42 +00:00
shared.c: Only setenv() if value is non-null
Some setenv() implementations (e.g. the one in OpenBSD's stdlib) segfault if we pass a NULL value. Only set environment variables if the corresponding settings are defined to avoid this. Note that this is a minor behaviour change as environment variables were supposed to be set to an empty string if a setting was undefined. Given that this feature isn't part of any official release yet, there's no need to worry about backwards compatibility, really. Change the documentation accordingly. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
This commit is contained in:
parent
8185169e5e
commit
d96d2c98eb
@ -500,7 +500,7 @@ Also, all filters are handed the following environment variables:
|
|||||||
|
|
||||||
If a setting is not defined for a repository and the corresponding global
|
If a setting is not defined for a repository and the corresponding global
|
||||||
setting is also not defined (if applicable), then the corresponding
|
setting is also not defined (if applicable), then the corresponding
|
||||||
environment variable will be an empty string.
|
environment variable will be unset.
|
||||||
|
|
||||||
|
|
||||||
MACRO EXPANSION
|
MACRO EXPANSION
|
||||||
|
2
shared.c
2
shared.c
@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
|
|||||||
p = env_vars;
|
p = env_vars;
|
||||||
q = p + env_var_count;
|
q = p + env_var_count;
|
||||||
for (; p < q; p++)
|
for (; p < q; p++)
|
||||||
if (setenv(p->name, p->value, 1))
|
if (p->value && setenv(p->name, p->value, 1))
|
||||||
fprintf(stderr, warn, p->name, p->value);
|
fprintf(stderr, warn, p->name, p->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user