all repos — cgit @ 8d8e84e72a24f474a6659ca04d0906723b2ac975

a hyperfast web frontend for git written in c

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>
Lukas Fleischer cgit@cryptocrack.de
Wed, 10 Apr 2013 12:30:52 +0200
commit

8d8e84e72a24f474a6659ca04d0906723b2ac975

parent

410da3ac1cdb002116c08f143ce82534897ede27

1 files changed, 4 insertions(+), 2 deletions(-)

jump to
M cgit.ccgit.c

@@ -486,8 +486,10 @@ setup_git_directory_gently(&nongit);

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;