From 8c10549ac89718c5693c5ae1d743b40b65142440 Mon Sep 17 00:00:00 2001 From: Sergey Khodych Date: Thu, 28 May 2009 05:17:03 +0300 Subject: comctl32:rebar: Don't store an empty string in REBAR_SetBandInfoT. --- dlls/comctl32/rebar.c | 14 ++++++++++---- dlls/comctl32/tests/rebar.c | 12 ++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c index 8aafdb9..0c95ab3 100644 --- a/dlls/comctl32/rebar.c +++ b/dlls/comctl32/rebar.c @@ -2664,10 +2664,16 @@ REBAR_SetBandInfoT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnic uChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand); if (lprbbi->fMask & RBBIM_TEXT) { LPWSTR wstr = NULL; - if (bUnicode) - Str_SetPtrW(&wstr, lprbbi->lpText); - else - Str_SetPtrAtoW(&wstr, (LPSTR)lprbbi->lpText); + if (lprbbi->lpText) { + if (bUnicode) { + if (lstrlenW(lprbbi->lpText)) + Str_SetPtrW(&wstr, lprbbi->lpText); + } + else { + if (*(LPSTR)lprbbi->lpText) + Str_SetPtrAtoW(&wstr, (LPSTR)lprbbi->lpText); + } + } if (REBAR_strdifW(wstr, lpBand->lpText)) { Free(lpBand->lpText); diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c index 0064c45..a05073c 100644 --- a/dlls/comctl32/tests/rebar.c +++ b/dlls/comctl32/tests/rebar.c @@ -292,6 +292,9 @@ rbsize_result_t rbsize_results[] = { { {0, 0, 672, 20}, 20, 1, {20, }, 2, { { { 0, 0, 83, 20}, 0x00, 83}, { {83, 0, 672, 20}, 0x00, 589}, }, }, + { {0, 0, 672, 20}, 20, 1, {20, }, 2, { + { { 0, 0, 619, 20}, 0x00, 619}, { {619, 0, 672, 20}, 0x00, 53}, + }, }, }; static int rbsize_numtests = 0; @@ -353,6 +356,7 @@ static void layout_test(void) REBARBANDINFO rbi; HIMAGELIST himl; REBARINFO ri; + CHAR emptystr[] = ""; rebuild_rebar(&hRebar); check_sizes(); @@ -511,6 +515,14 @@ static void layout_test(void) SendMessageA(hRebar, RB_MAXIMIZEBAND, 1, FALSE); check_sizes(); + rbi.fMask = RBBIM_TEXT; + rbi.lpText = NULL; + ok(SendMessage(hRebar, RB_SETBANDINFO, 0, (LPARAM)&rbi),"RB_SETBARINFO failed\n"); + rbi.lpText = emptystr; + ok(SendMessage(hRebar, RB_SETBANDINFO, 1, (LPARAM)&rbi),"RB_SETBARINFO failed\n"); + SendMessageA(hRebar, RB_MAXIMIZEBAND, 0, FALSE); + check_sizes(); + DestroyWindow(hRebar); } -- 1.5.3.3