Nikolay Sivov : comctl32/listview: Return earlier on allocation failure ( Coverity).

Alexandre Julliard julliard at winehq.org
Thu Aug 4 17:20:18 CDT 2016


Module: wine
Branch: master
Commit: 622a24046f9c06078e1e7b27726f90b6fa9b1e0f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=622a24046f9c06078e1e7b27726f90b6fa9b1e0f

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Aug  4 10:57:47 2016 +0300

comctl32/listview: Return earlier on allocation failure (Coverity).

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 6ab360b..cc1721b 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);
         }
     }
 




More information about the wine-cvs mailing list