oleacc: Don't return partial data in GetRoleTextA if buffer is too small.

This commit is contained in:
Piotr Caban 2014-05-15 17:52:52 +02:00 committed by Alexandre Julliard
parent 1f6ade45c1
commit dccc4283a7
2 changed files with 13 additions and 4 deletions

View File

@ -396,6 +396,12 @@ UINT WINAPI GetRoleTextA(DWORD role, LPSTR lpRole, UINT rolemax)
return length - 1;
}
if(rolemax < length) {
HeapFree(GetProcessHeap(), 0, roletextW);
lpRole[0] = 0;
return 0;
}
WideCharToMultiByte( CP_ACP, 0, roletextW, -1, lpRole, rolemax, NULL, NULL );
if(rolemax < length){

View File

@ -87,13 +87,16 @@ static void test_getroletext(void)
ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 1);
ok(ret == 0, "GetRoleTextA returned wrong length\n");
ok(buf[0] == '\0', "GetRoleTextA returned not zero-length buffer\n");
buf[1] = '*';
buf[0] = '*';
ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 2);
ok(ret == 1 ||
ok(broken(ret == 1) ||
ret == 0, /* Vista and W2K8 */
"GetRoleTextA returned wrong length, got %d, expected 0 or 1\n", ret);
if (ret == 1)
ok(buf[1] == '\0', "GetRoleTextA returned not zero-length buffer : (%c)\n", buf[1]);
if (ret == 0) {
ok(!buf[0] ||
broken(buf[0]!='*') /* WinXP */,
"GetRoleTextA returned not zero-length buffer : (%c)\n", buf[0]);
}
bufW[0] = '*';
ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, bufW, 1);