Commit 24195610 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

comctl32: toolbar: Fix the TB_ADDSTRING from resources for a NUL delimiter.

parent 869c3bb7
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#define IDS_TBADD3 18 #define IDS_TBADD3 18
#define IDS_TBADD4 19 #define IDS_TBADD4 19
#define IDS_TBADD5 20 #define IDS_TBADD5 20
#define IDS_TBADD6 21
#define IDS_TBADD7 22 #define IDS_TBADD7 22
#define IDS_TBADD8 23
#define IDS_TBADD9 24
#endif /* __WINE_COMCTL32_TEST_RESOURCES_H */ #endif /* __WINE_COMCTL32_TEST_RESOURCES_H */
...@@ -37,7 +37,6 @@ STRINGTABLE ...@@ -37,7 +37,6 @@ STRINGTABLE
IDS_TBADD3 "*p*q*" IDS_TBADD3 "*p*q*"
IDS_TBADD4 "#p#q##" IDS_TBADD4 "#p#q##"
IDS_TBADD5 "|p||q|r|" IDS_TBADD5 "|p||q|r|"
IDS_TBADD6 "\000a\000\000"
IDS_TBADD7 "abracadabra" IDS_TBADD7 "abracadabra"
} }
......
...@@ -362,9 +362,6 @@ void test_add_string() ...@@ -362,9 +362,6 @@ void test_add_string()
ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD5); ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD5);
ok(ret == 8, "TB_ADDSTRINGA - unexpected return %d\n", ret); ok(ret == 8, "TB_ADDSTRINGA - unexpected return %d\n", ret);
CHECK_STRING_TABLE(11, ret6); 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); ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD7);
ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret); ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret);
CHECK_STRING_TABLE(14, ret7); CHECK_STRING_TABLE(14, ret7);
......
...@@ -2921,9 +2921,8 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2921,9 +2921,8 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
INT len; INT len;
TRACE("adding string from resource!\n"); TRACE("adding string from resource!\n");
LoadStringW ((HINSTANCE)wParam, (UINT)lParam, len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
szString, MAX_RESOURCE_STRING_LENGTH); szString, MAX_RESOURCE_STRING_LENGTH);
len = lstrlenW(szString);
TRACE("len=%d %s\n", len, debugstr_w(szString)); TRACE("len=%d %s\n", len, debugstr_w(szString));
if (len == 0 || len == 1) if (len == 0 || len == 1)
...@@ -2932,11 +2931,15 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2932,11 +2931,15 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
TRACE("Delimiter: 0x%x\n", *szString); TRACE("Delimiter: 0x%x\n", *szString);
delimiter = *szString; delimiter = *szString;
p = szString + 1; p = szString + 1;
if (szString[len-1] == delimiter)
szString[len-1] = 0;
while ((next_delim = strchrW(p, delimiter)) != NULL) { while ((next_delim = strchrW(p, delimiter)) != NULL) {
*next_delim = 0; *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)); infoPtr->strings = ReAlloc(infoPtr->strings, sizeof(LPWSTR)*(infoPtr->nNumStrings+1));
Str_SetPtrW(&infoPtr->strings[infoPtr->nNumStrings], p); Str_SetPtrW(&infoPtr->strings[infoPtr->nNumStrings], p);
......
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