From 241956101e52877691b78f8bdc9870fb5a594d06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Miko=C5=82aj=20Zalewski?= Date: Mon, 9 Oct 2006 00:06:59 +0200 Subject: [PATCH] comctl32: toolbar: Fix the TB_ADDSTRING from resources for a NUL delimiter. --- dlls/comctl32/tests/resources.h | 3 --- dlls/comctl32/tests/rsrc.rc | 1 - dlls/comctl32/tests/toolbar.c | 3 --- dlls/comctl32/toolbar.c | 11 +++++++---- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/dlls/comctl32/tests/resources.h b/dlls/comctl32/tests/resources.h index 826f9c53919..c99633d342d 100644 --- a/dlls/comctl32/tests/resources.h +++ b/dlls/comctl32/tests/resources.h @@ -29,9 +29,6 @@ #define IDS_TBADD3 18 #define IDS_TBADD4 19 #define IDS_TBADD5 20 -#define IDS_TBADD6 21 #define IDS_TBADD7 22 -#define IDS_TBADD8 23 -#define IDS_TBADD9 24 #endif /* __WINE_COMCTL32_TEST_RESOURCES_H */ diff --git a/dlls/comctl32/tests/rsrc.rc b/dlls/comctl32/tests/rsrc.rc index b68ab1bdc32..165dc15929d 100644 --- a/dlls/comctl32/tests/rsrc.rc +++ b/dlls/comctl32/tests/rsrc.rc @@ -37,7 +37,6 @@ STRINGTABLE IDS_TBADD3 "*p*q*" IDS_TBADD4 "#p#q##" IDS_TBADD5 "|p||q|r|" - IDS_TBADD6 "\000a\000\000" IDS_TBADD7 "abracadabra" } diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index b71962b131c..220d7032c2a 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -362,9 +362,6 @@ void test_add_string() ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD5); ok(ret == 8, "TB_ADDSTRINGA - unexpected return %d\n", ret); CHECK_STRING_TABLE(11, ret6); - ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD6); - ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret); - CHECK_STRING_TABLE(11, ret6); ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD7); ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret); CHECK_STRING_TABLE(14, ret7); diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 2c79051da44..e0d06ae3cdb 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -2921,9 +2921,8 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) INT len; TRACE("adding string from resource!\n"); - LoadStringW ((HINSTANCE)wParam, (UINT)lParam, + len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam, szString, MAX_RESOURCE_STRING_LENGTH); - len = lstrlenW(szString); TRACE("len=%d %s\n", len, debugstr_w(szString)); if (len == 0 || len == 1) @@ -2932,11 +2931,15 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) TRACE("Delimiter: 0x%x\n", *szString); delimiter = *szString; p = szString + 1; - if (szString[len-1] == delimiter) - szString[len-1] = 0; while ((next_delim = strchrW(p, delimiter)) != NULL) { *next_delim = 0; + if (next_delim + 1 >= szString + len) + { + /* this may happen if delimiter == '\0' or if the last char is a + * delimiter (then it is ignored like the native does) */ + break; + } infoPtr->strings = ReAlloc(infoPtr->strings, sizeof(LPWSTR)*(infoPtr->nNumStrings+1)); Str_SetPtrW(&infoPtr->strings[infoPtr->nNumStrings], p); -- 2.11.4.GIT