Trying to add a separator with an invalid pointer in iString to a toolbar works in Windows, showing that the field is ignored. --- dlls/comctl32/tests/toolbar.c | 51 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 1946095..91a72e0 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -1300,6 +1300,56 @@ static void test_getstring(void) DestroyWindow(hToolbar); } +static void test_deadbeef(void) +{ + HWND hToolbar = NULL; + TBBUTTON buttons[2]; + INT r; + + rebuild_toolbar_with_buttons(&hToolbar); + + ZeroMemory(&buttons, sizeof(buttons)); + + /* Some programs (e.g. Graphmatica 2.0f) forget to initialize the iString + * field for separators. If the random bit pattern of this field looks like + * a pointer, trying to follow it casues a crash (pagefault). This does not + * happen in Windows XP, 2008 or Vista, suggesting that this field is + * ignored in Windows in this case. */ + buttons[0].idCommand = 0; + buttons[0].fsStyle = BTNS_SEP; + buttons[0].fsState = TBSTATE_ENABLED; + buttons[0].iString = 0xdeadbeef; + +#if 0 + /* It is also possible that a poorly written program doesn't initialize the + * iString field of an actual button. Different versions of Windows seem to + * operate differently in this case. + * + Windows XP doesn't seem to be bothered in the least + * + Windows 2008 crashes + * + Windows Vista does not crash, but the subsequent TB_ADDBUTTONS + * call fails + * Since I know of no program that suffers from this particular issue, I'm + * commenting out this part of the test for the time being. If it gets + * uncommented, the subsequent TB_ADDBUTTONS should be adjusted + * appropriately. */ + + buttons[1].idCommand = 1; + buttons[1].fsStyle = BTNS_BUTTON; + buttons[1].fsState = 0; + buttons[1].iString = 0xdeadbeef; +#endif + + r = SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM)buttons); + expect(1, r); + + /* TODO: another test that might be worth doing, to get more insight on how + * Windows handles things, would be to introduce a separator with + * 0xdeadbeef as iString, and then change its style to make into a real + * button. */ + + DestroyWindow(hToolbar); +} + START_TEST(toolbar) { WNDCLASSA wc; @@ -1336,6 +1386,7 @@ START_TEST(toolbar) test_dispinfo(); test_setrows(); test_getstring(); + test_deadbeef(); PostQuitMessage(0); while(GetMessageA(&msg,0,0,0)) { -- 1.6.2.254.g84bde