[PATCH v4 3/7] comctl32/listbox: Use ULONG_PTR instead of DWORD when retrieving text without HAS_STRINGS

Gabriel Ivăncescu gabrielopcode at gmail.com
Tue Nov 13 04:35:59 CST 2018


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

The test has been updated to deal with the bug. This is clearly broken Windows
behavior, because the same 32-bit app returns a different size depending on
whether it's ran under WOW64 or natively 32-bit, and only with LB_GETTEXTLEN,
which makes no sense at all. So IMO we can choose which one to return here,
and size of a pointer simply makes more sense.

 dlls/comctl32/listbox.c       | 6 +++---
 dlls/comctl32/tests/listbox.c | 4 +---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c
index 4a2df52..76b09aa 100644
--- a/dlls/comctl32/listbox.c
+++ b/dlls/comctl32/listbox.c
@@ -762,8 +762,8 @@ static LRESULT LISTBOX_GetText( LB_DESCR *descr, INT index, LPWSTR buffer, BOOL
     } else
     {
         if (buffer)
-            *((DWORD *)buffer) = *(DWORD *)&descr->items[index].data;
-        len = sizeof(DWORD);
+            *((ULONG_PTR *)buffer) = descr->items[index].data;
+        len = sizeof(ULONG_PTR);
     }
     return len;
 }
@@ -2653,7 +2653,7 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam,
             SetLastError(ERROR_INVALID_INDEX);
             return LB_ERR;
         }
-        if (!HAS_STRINGS(descr)) return sizeof(DWORD);
+        if (!HAS_STRINGS(descr)) return sizeof(ULONG_PTR);
         return strlenW( descr->items[wParam].str );
 
     case LB_GETCURSEL:
diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c
index 6ac3c73..c63cccd 100644
--- a/dlls/comctl32/tests/listbox.c
+++ b/dlls/comctl32/tests/listbox.c
@@ -2296,12 +2296,10 @@ static void test_LBS_NODATA(void)
         ret = SendMessageA(listbox, LB_SETITEMDATA, valid_idx[i], 42);
         ok(ret == TRUE, "Unexpected return value %d.\n", ret);
         ret = SendMessageA(listbox, LB_GETTEXTLEN, valid_idx[i], 0);
-    todo_wine_if(text_len == 8)
-        ok(ret == text_len, "Unexpected return value %d.\n", ret);
+        ok(ret == sizeof(data) || broken(ret == text_len), "Unexpected return value %d.\n", ret);
 
         memset(&data, 0xee, sizeof(data));
         ret = SendMessageA(listbox, LB_GETTEXT, valid_idx[i], (LPARAM)&data);
-    todo_wine_if(sizeof(void *) == 8)
         ok(ret == sizeof(data), "Unexpected return value %d.\n", ret);
     todo_wine
         ok(!memcmp(&data, &zero_data, sizeof(data)), "Unexpected item data.\n");
-- 
2.19.1




More information about the wine-devel mailing list