From 9e82510ec8705c637c1d6f0c62b4dce7f04b0e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Gouget?= Date: Thu, 13 Jun 2002 22:04:45 +0000 Subject: [PATCH] Fix handling of strings that do not finish with "||". Fix the indentation of the while loop in TOOLBAR_AddStringW. --- dlls/comctl32/toolbar.c | 54 ++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 9db550f50a6..2785c2721b1 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -2477,31 +2477,38 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) { PWSTR p = szString + 1; - nIndex = infoPtr->nNumStrings; - while (*p != L'|') { + nIndex = infoPtr->nNumStrings; + while (*p != L'|' && *p != L'\0') { + PWSTR np; - if (infoPtr->nNumStrings == 0) { - infoPtr->strings = - COMCTL32_Alloc (sizeof(LPWSTR)); - } - else { - LPWSTR *oldStrings = infoPtr->strings; - infoPtr->strings = - COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); - memcpy (&infoPtr->strings[0], &oldStrings[0], - sizeof(LPWSTR) * infoPtr->nNumStrings); - COMCTL32_Free (oldStrings); - } + if (infoPtr->nNumStrings == 0) { + infoPtr->strings = COMCTL32_Alloc (sizeof(LPWSTR)); + } + else + { + LPWSTR *oldStrings = infoPtr->strings; + infoPtr->strings = COMCTL32_Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); + memcpy(&infoPtr->strings[0], &oldStrings[0], + sizeof(LPWSTR) * infoPtr->nNumStrings); + COMCTL32_Free(oldStrings); + } - len = COMCTL32_StrChrW (p, L'|') - p; - TRACE("len=%d %s\n", len, debugstr_w(p)); - infoPtr->strings[infoPtr->nNumStrings] = - COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); - lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1); - infoPtr->nNumStrings++; + np=COMCTL32_StrChrW (p, L'|'); + if (np!=NULL) { + len = np - p; + np++; + } else { + len = strlenW(p); + np = p + len; + } + TRACE("len=%d %s\n", len, debugstr_w(p)); + infoPtr->strings[infoPtr->nNumStrings] = + COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); + lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1); + infoPtr->nNumStrings++; - p += (len+1); - } + p = np; + } } else { @@ -2983,6 +2990,9 @@ TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) btnPtr = &infoPtr->buttons[nIndex]; + if(!btnPtr) + return -1; + if (lpTbInfo->dwMask & TBIF_COMMAND) lpTbInfo->idCommand = btnPtr->idCommand; if (lpTbInfo->dwMask & TBIF_IMAGE)