diff options
author | Lukas Fleischer | 2011-09-14 11:52:43 +0200 |
---|---|---|
committer | Lars Hjemli | 2012-01-03 14:59:36 +0000 |
commit | d96d2c98ebc4c2d3765f5b35c4142e0e828a421b (patch) | |
tree | 72e2ed0fd0dd949d400cf4b35f9496571488a2eb /shared.c | |
parent | 8185169e5e2a8b9438c7a6f3f9c5eb6db5a37fea (diff) | |
download | cgit-d96d2c98ebc4c2d3765f5b35c4142e0e828a421b.tar.gz cgit-d96d2c98ebc4c2d3765f5b35c4142e0e828a421b.tar.bz2 cgit-d96d2c98ebc4c2d3765f5b35c4142e0e828a421b.zip |
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>
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo) | |||
392 | p = env_vars; | 392 | p = env_vars; |
393 | q = p + env_var_count; | 393 | q = p + env_var_count; |
394 | for (; p < q; p++) | 394 | for (; p < q; p++) |
395 | if (setenv(p->name, p->value, 1)) | 395 | if (p->value && setenv(p->name, p->value, 1)) |
396 | fprintf(stderr, warn, p->name, p->value); | 396 | fprintf(stderr, warn, p->name, p->value); |
397 | } | 397 | } |
398 | 398 | ||