summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAditya Mandaleeka <adityamandaleeka@users.noreply.github.com>2017-04-04 13:10:40 -0700
committerGitHub <noreply@github.com>2017-04-04 13:10:40 -0700
commit3bf3915549eaa3c475f9dd899d9a6265dcde9908 (patch)
tree9db64513ebbfff431247ce9ca152d38fa92d5c1f /src
parent244dbfe0bfcb95d3c896c41a76e17bfba4f571c0 (diff)
parent443f2e5d907d16aba7a25d11ea418afc6ac69336 (diff)
downloadcoreclr-3bf3915549eaa3c475f9dd899d9a6265dcde9908.tar.gz
coreclr-3bf3915549eaa3c475f9dd899d9a6265dcde9908.tar.bz2
coreclr-3bf3915549eaa3c475f9dd899d9a6265dcde9908.zip
Merge pull request #10699 from adityamandaleeka/fix_env_empty_var_handling
Fix handling of empty environment variables in PAL
Diffstat (limited to 'src')
-rw-r--r--src/pal/src/misc/environ.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pal/src/misc/environ.cpp b/src/pal/src/misc/environ.cpp
index fed7b69f38..9fc13467c5 100644
--- a/src/pal/src/misc/environ.cpp
+++ b/src/pal/src/misc/environ.cpp
@@ -218,7 +218,13 @@ GetEnvironmentVariableW(
}
else if (size == 0)
{
- // handle error in GetEnvironmentVariableA
+ // If size is 0, it either means GetEnvironmentVariableA failed, or that
+ // it succeeded and the value of the variable is empty. Check GetLastError
+ // to determine which. If the call failed, we won't touch the buffer.
+ if (GetLastError() == ERROR_SUCCESS)
+ {
+ *lpBuffer = '\0';
+ }
}
else
{