aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/getenv.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/getenv.c b/lib/getenv.c
index 0c23e76aa..941ee8535 100644
--- a/lib/getenv.c
+++ b/lib/getenv.c
@@ -41,12 +41,13 @@ char *GetEnv(char *variable)
char env[MAX_PATH]; /* MAX_PATH is from windef.h */
char *temp = getenv(variable);
env[0] = '\0';
- ExpandEnvironmentStrings(temp, env, sizeof(env));
+ if (temp != NULL)
+ ExpandEnvironmentStrings(temp, env, sizeof(env));
#else
/* no length control */
char *env = getenv(variable);
#endif
- return env?strdup(env):NULL;
+ return (env && env[0])?strdup(env):NULL;
}
char *curl_getenv(char *v)