Commit 26067cc0 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/toolbar: Protect from NULL pointer access in TB_GETBUTTONINFOW handler.

parent 904c695d
......@@ -1710,12 +1710,13 @@ static void test_recalc(void)
static void test_getbuttoninfo(void)
{
HWND hToolbar = NULL;
TBBUTTONINFOW tbiW;
TBBUTTONINFOA tbi;
int i;
rebuild_toolbar_with_buttons(&hToolbar);
for (i = 0; i < 128; i++)
{
TBBUTTONINFOA tbi;
int ret;
tbi.cbSize = i;
......@@ -1727,6 +1728,14 @@ static void test_getbuttoninfo(void)
compare(ret, -1, "%d");
}
}
/* TBIF_TEXT with NULL pszText */
memset(&tbiW, 0, sizeof(tbiW));
tbiW.cbSize = sizeof(tbiW);
tbiW.dwMask = TBIF_BYINDEX | TBIF_STYLE | TBIF_COMMAND | TBIF_TEXT;
i = SendMessageA(hToolbar, TB_GETBUTTONINFOW, 1, (LPARAM)&tbiW);
ok(i == 1, "Got index %d\n", i);
DestroyWindow(hToolbar);
}
......
......@@ -3397,7 +3397,7 @@ TOOLBAR_GetButtonInfoT(const TOOLBAR_INFO *infoPtr, INT Id, LPTBBUTTONINFOW lpTb
Str_GetPtrW(lpText, lpTbInfo->pszText, lpTbInfo->cchText);
else
Str_GetPtrWtoA(lpText, (LPSTR)lpTbInfo->pszText, lpTbInfo->cchText);
} else
} else if (!bUnicode || lpTbInfo->pszText)
lpTbInfo->pszText[0] = '\0';
}
return nIndex;
......
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