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

msvcrt: Fix _dupenv_s behavior with missing env var.

parent 6017344e
...@@ -197,11 +197,8 @@ static void test_dupenv_s(void) ...@@ -197,11 +197,8 @@ static void test_dupenv_s(void)
len = 0xdeadbeef; len = 0xdeadbeef;
tmp = (void *)0xdeadbeef; tmp = (void *)0xdeadbeef;
ret = p_dupenv_s( &tmp, &len, "nonexistent" ); ret = p_dupenv_s( &tmp, &len, "nonexistent" );
todo_wine
ok( !ret, "_dupenv_s returned %d\n", ret ); ok( !ret, "_dupenv_s returned %d\n", ret );
todo_wine
ok( !len, "_dupenv_s returned length is %Id\n", len ); ok( !len, "_dupenv_s returned length is %Id\n", len );
todo_wine
ok( !tmp, "_dupenv_s returned pointer is %p\n", tmp ); ok( !tmp, "_dupenv_s returned pointer is %p\n", tmp );
} }
......
...@@ -249,7 +249,12 @@ int CDECL _dupenv_s(char **buffer, size_t *numberOfElements, const char *varname ...@@ -249,7 +249,12 @@ int CDECL _dupenv_s(char **buffer, size_t *numberOfElements, const char *varname
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 = getenv(varname))) return *_errno() = EINVAL; if (!(e = getenv(varname)))
{
*buffer = NULL;
if (numberOfElements) *numberOfElements = 0;
return 0;
}
sz = strlen(e) + 1; sz = strlen(e) + 1;
if (!(*buffer = malloc(sz))) if (!(*buffer = malloc(sz)))
......
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