在 2025-12-29 02:01, Pali Rohár 写道:
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;
I don't think this change is correct. Microsoft doc says that `getenv_s()` returns `EINVAL` (and not zero) in this case: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/getenv-s-wgetenv-s?view=msvc-170#error-conditions



--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

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

Reply via email to