summaryrefslogtreecommitdiff
path: root/src/pal/src/misc/environ.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/src/misc/environ.cpp')
-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
{