This special case does not throw an exception from invalid parameter handler.
---
 mingw-w64-crt/secapi/getenv_s.c                   | 6 +++---
 mingw-w64-libraries/winstorecompat/src/getenv_s.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/mingw-w64-crt/secapi/getenv_s.c b/mingw-w64-crt/secapi/getenv_s.c
index b2731830df98..0b31f418833c 100644
--- a/mingw-w64-crt/secapi/getenv_s.c
+++ b/mingw-w64-crt/secapi/getenv_s.c
@@ -23,15 +23,15 @@ static errno_t __cdecl emu_getenv_s(size_t *pReturnValue, 
char *dstBuf, rsize_t
         return errno = EINVAL;
     }
 
+    /* After passing parameter validation, the errno is not changed. */
+
     if (!varName) {
         *pReturnValue = 0;
         if (dstBuf)
             dstBuf[0] = '\0';
-        return errno = EINVAL;
+        return 0;
     }
 
-    /* After passing parameter validation, the errno is not changed. */
-
     value = getenv(varName);
     if (!value) {
         *pReturnValue = 0;
diff --git a/mingw-w64-libraries/winstorecompat/src/getenv_s.c 
b/mingw-w64-libraries/winstorecompat/src/getenv_s.c
index 5988082fab32..e6b2e150f24b 100644
--- a/mingw-w64-libraries/winstorecompat/src/getenv_s.c
+++ b/mingw-w64-libraries/winstorecompat/src/getenv_s.c
@@ -24,15 +24,15 @@ errno_t __cdecl getenv_s(size_t *pReturnValue, char 
*dstBuf, rsize_t dstSize, co
         return errno = EINVAL;
     }
 
+    /* After passing parameter validation, the errno is not changed. */
+
     if (!varName) {
         *pReturnValue = 0;
         if (dstBuf)
             dstBuf[0] = '\0';
-        return errno = EINVAL;
+        return 0;
     }
 
-    /* After passing parameter validation, the errno is not changed. */
-
     /*
      * Function GetEnvironmentVariableA() is documented on:
      * 
https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getenvironmentvariablea
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to