summaryrefslogtreecommitdiff
path: root/src/pal
diff options
context:
space:
mode:
authorAditya Mandaleeka <adityam@microsoft.com>2017-04-04 10:31:46 -0700
committerAditya Mandaleeka <adityam@microsoft.com>2017-04-04 10:49:23 -0700
commit443f2e5d907d16aba7a25d11ea418afc6ac69336 (patch)
tree3ab7673185fcbcb0bf89593c34a34218e1c100d3 /src/pal
parent14b09e8777615f57fc1e78c0c7775962ee5b44a0 (diff)
downloadcoreclr-443f2e5d907d16aba7a25d11ea418afc6ac69336.tar.gz
coreclr-443f2e5d907d16aba7a25d11ea418afc6ac69336.tar.bz2
coreclr-443f2e5d907d16aba7a25d11ea418afc6ac69336.zip
Fix handling of empty environment variables in PAL.
Diffstat (limited to 'src/pal')
-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
{