Commit c6dd1419 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Fix parameter validation for LVM_SETITEMTEXT.

parent 2096d901
...@@ -8785,7 +8785,7 @@ static BOOL LISTVIEW_SetItemTextT(LISTVIEW_INFO *infoPtr, INT nItem, const LVITE ...@@ -8785,7 +8785,7 @@ static BOOL LISTVIEW_SetItemTextT(LISTVIEW_INFO *infoPtr, INT nItem, const LVITE
{ {
LVITEMW lvItem; LVITEMW lvItem;
if (nItem < 0 && nItem >= infoPtr->nItemCount) return FALSE; if (!lpLVItem || nItem < 0 || nItem >= infoPtr->nItemCount) return FALSE;
lvItem.iItem = nItem; lvItem.iItem = nItem;
lvItem.iSubItem = lpLVItem->iSubItem; lvItem.iSubItem = lpLVItem->iSubItem;
......
...@@ -4710,6 +4710,40 @@ static void test_dispinfo(void) ...@@ -4710,6 +4710,40 @@ static void test_dispinfo(void)
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
static void test_LVM_SETITEMTEXT(void)
{
static char testA[] = "TEST";
LVITEMA item;
HWND hwnd;
DWORD ret;
hwnd = create_listview_control(LVS_ICON);
ok(hwnd != NULL, "failed to create listview window\n");
insert_item(hwnd, 0);
/* null item pointer */
ret = SendMessage(hwnd, LVM_SETITEMTEXTA, 0, 0);
expect(FALSE, ret);
ret = SendMessage(hwnd, LVM_SETITEMTEXTW, 0, 0);
expect(FALSE, ret);
/* index out of bounds */
item.pszText = testA;
item.cchTextMax = 0; /* ignored */
ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 1, (LPARAM)&item);
expect(FALSE, ret);
ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, -1, (LPARAM)&item);
expect(FALSE, ret);
ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
expect(TRUE, ret);
DestroyWindow(hwnd);
}
START_TEST(listview) START_TEST(listview)
{ {
HMODULE hComctl32; HMODULE hComctl32;
...@@ -4774,6 +4808,7 @@ START_TEST(listview) ...@@ -4774,6 +4808,7 @@ START_TEST(listview)
test_destroynotify(); test_destroynotify();
test_createdragimage(); test_createdragimage();
test_dispinfo(); test_dispinfo();
test_LVM_SETITEMTEXT();
if (!load_v6_module(&ctx_cookie, &hCtx)) if (!load_v6_module(&ctx_cookie, &hCtx))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment