* [PATCH] cgit.c: Do not restore unset environment variables
@ 2013-04-10 10:30 cgit
2013-04-10 11:46 ` Jason
0 siblings, 1 reply; 2+ messages in thread
From: cgit @ 2013-04-10 10:30 UTC (permalink / raw)
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 at cryptocrack.de>
---
cgit.c | 6 ++++--
1 file 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;
--
1.8.2.675.gda3bb24.dirty
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] cgit.c: Do not restore unset environment variables
2013-04-10 10:30 [PATCH] cgit.c: Do not restore unset environment variables cgit
@ 2013-04-10 11:46 ` Jason
0 siblings, 0 replies; 2+ messages in thread
From: Jason @ 2013-04-10 11:46 UTC (permalink / raw)
Good catch. Applied to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-10 11:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10 10:30 [PATCH] cgit.c: Do not restore unset environment variables cgit
2013-04-10 11:46 ` Jason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).