user32: Fix LoadStringA behavior on 1-character long buffer.
This commit is contained in:
parent
544816797a
commit
c2df317c4b
|
@ -310,7 +310,8 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id, LPSTR buffer, INT
|
||||||
|
|
||||||
while (id--) p += *p + 1;
|
while (id--) p += *p + 1;
|
||||||
|
|
||||||
RtlUnicodeToMultiByteN( buffer, buflen - 1, &retval, p + 1, *p * sizeof(WCHAR) );
|
if (buflen != 1)
|
||||||
|
RtlUnicodeToMultiByteN( buffer, buflen - 1, &retval, p + 1, *p * sizeof(WCHAR) );
|
||||||
}
|
}
|
||||||
buffer[retval] = 0;
|
buffer[retval] = 0;
|
||||||
TRACE("returning %s\n", debugstr_a(buffer));
|
TRACE("returning %s\n", debugstr_a(buffer));
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue