Commit ad9303d8 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

user32: Put 0 to output string even for 1 char buffer in LoadStringW().

parent 726027d6
...@@ -185,17 +185,10 @@ INT WINAPI DECLSPEC_HOTPATCH LoadStringW( HINSTANCE instance, UINT resource_id, ...@@ -185,17 +185,10 @@ INT WINAPI DECLSPEC_HOTPATCH LoadStringW( HINSTANCE instance, UINT resource_id,
} }
i = min(buflen - 1, *p); i = min(buflen - 1, *p);
if (i > 0) { memcpy(buffer, p + 1, i * sizeof(WCHAR));
memcpy(buffer, p + 1, i * sizeof (WCHAR)); buffer[i] = 0;
buffer[i] = 0;
} else {
if (buflen > 1) {
buffer[0] = 0;
return 0;
}
}
TRACE("%s loaded !\n", debugstr_w(buffer)); TRACE("returning %s\n", debugstr_w(buffer));
return i; return i;
} }
......
...@@ -147,6 +147,15 @@ static void test_LoadStringW(void) ...@@ -147,6 +147,15 @@ static void test_LoadStringW(void)
"got %lu.\n", GetLastError()); "got %lu.\n", GetLastError());
ok(!returnedstringw[0], "got %#x.\n", returnedstringw[0]); ok(!returnedstringw[0], "got %#x.\n", returnedstringw[0]);
ok(returnedstringw[1] == 0xcccc, "got %#x.\n", returnedstringw[1]); ok(returnedstringw[1] == 0xcccc, "got %#x.\n", returnedstringw[1]);
/* Test short buffer */
SetLastError(0xdeadbeef);
memset(returnedstringw, 0xcc, sizeof(returnedstringw));
length1 = LoadStringW(hInst, 2, returnedstringw, 1); /* get resource string */
ok(!length1, "got %d.\n", length1);
ok(GetLastError() == 0xdeadbeef, "got %lu.\n", GetLastError());
ok(!returnedstringw[0], "got %#x.\n", returnedstringw[0]);
ok(returnedstringw[1] == 0xcccc, "got %#x.\n", returnedstringw[1]);
} }
static void test_LoadStringA (void) static void test_LoadStringA (void)
......
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