Piotr Caban : oleacc: Modify output buffer on incorrect role in GetRoleTextA.

Alexandre Julliard julliard at winehq.org
Thu May 15 15:14:30 CDT 2014


Module: wine
Branch: master
Commit: 1f6ade45c1f7546e4f66378793af2feb79824c55
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1f6ade45c1f7546e4f66378793af2feb79824c55

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu May 15 17:52:33 2014 +0200

oleacc: Modify output buffer on incorrect role in GetRoleTextA.

---

 dlls/oleacc/main.c       |    8 +++++++-
 dlls/oleacc/tests/main.c |   12 ++++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/dlls/oleacc/main.c b/dlls/oleacc/main.c
index 89c0142..3634991 100644
--- a/dlls/oleacc/main.c
+++ b/dlls/oleacc/main.c
@@ -373,9 +373,15 @@ UINT WINAPI GetRoleTextA(DWORD role, LPSTR lpRole, UINT rolemax)
 
     TRACE("%u %p %u\n", role, lpRole, rolemax);
 
+    if(lpRole && !rolemax)
+        return 0;
+
     length = GetRoleTextW(role, NULL, 0);
-    if((length == 0) || (lpRole && !rolemax))
+    if(!length) {
+        if(lpRole && rolemax)
+            lpRole[0] = 0;
         return 0;
+    }
 
     roletextW = HeapAlloc(GetProcessHeap(), 0, (length + 1)*sizeof(WCHAR));
     if(!roletextW)
diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c
index 76ea969..121a5d7 100644
--- a/dlls/oleacc/tests/main.c
+++ b/dlls/oleacc/tests/main.c
@@ -38,8 +38,8 @@ static void test_getroletext(void)
     buf[0] = '*';
     ret = GetRoleTextA(-1, buf, 2);
     ok(ret == 0, "GetRoleTextA doesn't return zero on wrong role number, got %d\n", ret);
-    ok(buf[0] == '*' ||
-       broken(buf[0] == 0), /* Win98 and WinMe */
+    ok(buf[0] == 0 ||
+       broken(buf[0] == '*'), /* Win98 and WinMe */
        "GetRoleTextA modified buffer on wrong role number\n");
     buf[0] = '*';
     ret = GetRoleTextA(-1, buf, 0);
@@ -75,6 +75,14 @@ static void test_getroletext(void)
     ok(ret > 0, "GetRoleTextW doesn't return length on NULL buffer, got %d\n", ret);
 
     /* use a smaller buffer */
+    bufW[0] = '*';
+    ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 0);
+    ok(!ret, "GetRoleTextA doesn't return 0, got %d\n", ret);
+    ok(buf[0] == '*', "GetRoleTextA modified buffer\n");
+    buffW = NULL;
+    ret = GetRoleTextW(ROLE_SYSTEM_TITLEBAR, (WCHAR*)&buffW, 0);
+    ok(ret, "GetRoleTextW doesn't return length\n");
+    ok(buffW != NULL, "GetRoleTextW doesn't modify buffer\n");
     buf[0] = '*';
     ret = GetRoleTextA(ROLE_SYSTEM_TITLEBAR, buf, 1);
     ok(ret == 0, "GetRoleTextA returned wrong length\n");




More information about the wine-cvs mailing list