From 622a24046f9c06078e1e7b27726f90b6fa9b1e0f Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 4 Aug 2016 10:57:47 +0300 Subject: [PATCH] comctl32/listview: Return earlier on allocation failure (Coverity). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/listview.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 6ab360b6639..cc1721b6b8e 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -5863,13 +5863,15 @@ static BOOL LISTVIEW_EndEditLabelT(LISTVIEW_INFO *infoPtr, BOOL storeText, BOOL { DWORD len = isW ? GetWindowTextLengthW(infoPtr->hwndEdit) : GetWindowTextLengthA(infoPtr->hwndEdit); - if (len) + if (len++) { - if ((pszText = Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR))))) - { - if (isW) GetWindowTextW(infoPtr->hwndEdit, pszText, len+1); - else GetWindowTextA(infoPtr->hwndEdit, (CHAR*)pszText, len+1); - } + 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); } } -- 2.11.4.GIT