Commit aafef01c authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

msvcrt: Fix _wdupenv_s behavior with missing env var.

parent 5a08eab3
...@@ -211,11 +211,8 @@ static void test_wdupenv_s(void) ...@@ -211,11 +211,8 @@ static void test_wdupenv_s(void)
len = 0xdeadbeef; len = 0xdeadbeef;
tmp = (void *)0xdeadbeef; tmp = (void *)0xdeadbeef;
ret = p_wdupenv_s( &tmp, &len, L"nonexistent" ); ret = p_wdupenv_s( &tmp, &len, L"nonexistent" );
todo_wine
ok( !ret, "_wdupenv_s returned %d\n", ret ); ok( !ret, "_wdupenv_s returned %d\n", ret );
todo_wine
ok( !len, "_wdupenv_s returned length is %Id\n", len ); ok( !len, "_wdupenv_s returned length is %Id\n", len );
todo_wine
ok( !tmp, "_wdupenv_s returned pointer is %p\n", tmp ); ok( !tmp, "_wdupenv_s returned pointer is %p\n", tmp );
} }
......
...@@ -279,7 +279,12 @@ int CDECL _wdupenv_s(wchar_t **buffer, size_t *numberOfElements, ...@@ -279,7 +279,12 @@ int CDECL _wdupenv_s(wchar_t **buffer, size_t *numberOfElements,
if (!MSVCRT_CHECK_PMT(buffer != NULL)) return EINVAL; if (!MSVCRT_CHECK_PMT(buffer != NULL)) return EINVAL;
if (!MSVCRT_CHECK_PMT(varname != NULL)) return EINVAL; if (!MSVCRT_CHECK_PMT(varname != NULL)) return EINVAL;
if (!(e = _wgetenv(varname))) return *_errno() = EINVAL; if (!(e = _wgetenv(varname)))
{
*buffer = NULL;
if (numberOfElements) *numberOfElements = 0;
return 0;
}
sz = wcslen(e) + 1; sz = wcslen(e) + 1;
if (!(*buffer = malloc(sz * sizeof(wchar_t)))) if (!(*buffer = malloc(sz * sizeof(wchar_t))))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment