Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.zx2c4.com/cgit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cgit.c
diff options
context:
space:
mode:
authorLukas Fleischer <cgit@cryptocrack.de>2013-04-10 14:30:52 +0400
committerJason A. Donenfeld <Jason@zx2c4.com>2013-04-10 15:46:30 +0400
commit8d8e84e72a24f474a6659ca04d0906723b2ac975 (patch)
tree60942d045a435c87284da5a21df7be407e7c7978 /cgit.c
parent410da3ac1cdb002116c08f143ce82534897ede27 (diff)
cgit.c: Do not restore unset environment variables
getenv() returns a NULL pointer if the specified variable name cannot be found in the environment. However, some setenv() implementations crash if a NULL pointer is passed as second argument. Only restore variables that are not NULL. See commit d96d2c98ebc4c2d3765f5b35c4142e0e828a421b for a related patch. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/cgit.c b/cgit.c
index 0bf8972..4dadd97 100644
--- a/cgit.c
+++ b/cgit.c
@@ -486,8 +486,10 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
init_display_notes(NULL);
/* We restore the unset variables afterward. */
- setenv("HOME", user_home, 1);
- setenv("XDG_CONFIG_HOME", xdg_home, 1);
+ if (user_home)
+ setenv("HOME", user_home, 1);
+ if (xdg_home)
+ setenv("XDG_CONFIG_HOME", xdg_home, 1);
if (nongit) {
const char *name = ctx->repo->name;