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

comctl32/comboex: Handle NULL item text case to avoid crash.

parent d7a9e2d2
......@@ -510,6 +510,17 @@ static UINT COMBOEX_GetListboxText(const COMBOEX_INFO *infoPtr, INT_PTR n, LPWST
return 0;
str = COMBOEX_GetText(infoPtr, item);
if (!str)
{
if (buf)
{
if (infoPtr->unicode)
buf[0] = 0;
else
*((LPSTR)buf) = 0;
}
return 0;
}
if (infoPtr->unicode)
{
......
......@@ -288,6 +288,41 @@ static void test_WM_LBUTTONDOWN(void)
DestroyWindow(hComboEx);
}
static void test_CB_GETLBTEXT(void)
{
HWND hCombo;
CHAR buff[1];
COMBOBOXEXITEMA item;
LRESULT ret;
hCombo = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
/* set text to null */
addItem(hCombo, 0, NULL);
buff[0] = 'a';
item.mask = CBEIF_TEXT;
item.iItem = 0;
item.pszText = buff;
item.cchTextMax = 1;
ret = SendMessage(hCombo, CBEM_GETITEMA, 0, (LPARAM)&item);
ok(ret != 0, "CBEM_GETITEM failed\n");
ok(buff[0] == 0, "\n");
ret = SendMessage(hCombo, CB_GETLBTEXTLEN, 0, 0);
ok(ret == 0, "Expected zero length\n");
ret = SendMessage(hCombo, CB_GETLBTEXTLEN, 0, 0);
ok(ret == 0, "Expected zero length\n");
buff[0] = 'a';
ret = SendMessage(hCombo, CB_GETLBTEXT, 0, (LPARAM)buff);
ok(ret == 0, "Expected zero length\n");
ok(buff[0] == 0, "Expected null terminator as a string, got %s\n", buff);
DestroyWindow(hCombo);
}
static LRESULT CALLBACK ComboExTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
......@@ -362,6 +397,7 @@ START_TEST(comboex)
test_comboboxex();
test_WM_LBUTTONDOWN();
test_CB_GETLBTEXT();
cleanup();
}
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