Commit c2df317c authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

user32: Fix LoadStringA behavior on 1-character long buffer.

parent 54481679
...@@ -310,6 +310,7 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id, LPSTR buffer, INT ...@@ -310,6 +310,7 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id, LPSTR buffer, INT
while (id--) p += *p + 1; while (id--) p += *p + 1;
if (buflen != 1)
RtlUnicodeToMultiByteN( buffer, buflen - 1, &retval, p + 1, *p * sizeof(WCHAR) ); RtlUnicodeToMultiByteN( buffer, buflen - 1, &retval, p + 1, *p * sizeof(WCHAR) );
} }
buffer[retval] = 0; buffer[retval] = 0;
......
...@@ -126,6 +126,13 @@ static void test_LoadStringA (void) ...@@ -126,6 +126,13 @@ static void test_LoadStringA (void)
ok( ret == -1 || broken(ret == 0), ok( ret == -1 || broken(ret == 0),
"LoadStringA did not return -1 when called with buflen = 0, got %d, err %d\n", "LoadStringA did not return -1 when called with buflen = 0, got %d, err %d\n",
ret, GetLastError()); ret, GetLastError());
SetLastError(0xdeadbeef);
buf[0] = 'a';
ret = LoadStringA(hInst, 1, buf, 1);
ok( !ret, "LoadString returned %d\n", ret);
ok( buf[0] == 0, "buf[0] = %c (%x)\n", buf[0], buf[0]);
ok( GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
} }
static void test_accel1(void) static void test_accel1(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