Module: wine Branch: master Commit: dccc4283a7848eafc53d99512bc39d1d8bacb018 URL: http://source.winehq.org/git/wine.git/?a=commit;h=dccc4283a7848eafc53d99512b...
Author: Piotr Caban piotr@codeweavers.com Date: Thu May 15 17:52:52 2014 +0200
oleacc: Don't return partial data in GetRoleTextA if buffer is too small.
---
dlls/oleacc/main.c | 6 ++++++ dlls/oleacc/tests/main.c | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/oleacc/main.c b/dlls/oleacc/main.c index 3634991..37d2269 100644 --- a/dlls/oleacc/main.c +++ b/dlls/oleacc/main.c @@ -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){ diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c index 121a5d7..be30da3 100644 --- a/dlls/oleacc/tests/main.c +++ b/dlls/oleacc/tests/main.c @@ -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);