From: Anders Kjersem andersdev@proton.me
--- dlls/comctl32/listview.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 1a0c919e962..d1d2f0ee263 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -5922,19 +5922,18 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL if (storeText) { DWORD len = isW ? GetWindowTextLengthW(infoPtr->hwndEdit) : GetWindowTextLengthA(infoPtr->hwndEdit); + ++len; /* Room for terminator (empty text must notify with "", not NULL) */
- if (len++) - { - if (!(pszText = Alloc(len * (isW ? sizeof(WCHAR) : sizeof(CHAR))))) - return FALSE; + if (!(pszText = Alloc(len * (isW ? sizeof(WCHAR) : sizeof(CHAR))))) + return FALSE;
- if (isW) - GetWindowTextW(infoPtr->hwndEdit, pszText, len); - else - GetWindowTextA(infoPtr->hwndEdit, (CHAR*)pszText, len); - } + if (isW) + GetWindowTextW(infoPtr->hwndEdit, pszText, len); + else + GetWindowTextA(infoPtr->hwndEdit, (CHAR*)pszText, len); }
+ TRACE("(pszText=%s, isW=%d)\n", debugtext_t(pszText, isW), isW);
ZeroMemory(&dispInfo, sizeof(dispInfo));
Hi, @anders. Thank you for this fix. I think it makes sense, but it needs some tests (see g_editbox_disp_info in existing tests), and some rewording for the subject line. It's still possible to get NULL text there, when text is "same". Also, previously zero-length string will cause early return and LISTVIEW_SetItemT() wasn't called. This also has to be tested.
On Mon Mar 17 15:58:58 2025 +0000, Nikolay Sivov wrote:
Hi, @anders. Thank you for this fix. I think it makes sense, but it needs some tests (see g_editbox_disp_info in existing tests), and some rewording for the subject line. It's still possible to get NULL text there, when text is "same". Also, previously zero-length string will cause early return and LISTVIEW_SetItemT() wasn't called. This also has to be tested.
NULL is same text (edit aborted by the user). From MSDN "If the user cancels editing or doesn't change the text and presses Enter key, the pszText member of the LVITEM structure is NULL"
Resubmitted with a test as !7602.
This merge request was closed by Zhiyi Zhang.