regedit: fixed a memory leak in listview.c (found by Smatch).

Lionel_Debroux lionel_debroux at yahoo.fr
Mon Sep 3 08:03:33 CDT 2007


get_item_text leaks some heap memory in an error path. Found in Michael
Stefaniuc's list of potential Wine bugs detected by Smatch.

2007-09-03  Lionel Debroux <lionel_debroux at yahoo.fr>
       * programs/regedit/listview.c:
       regedit: fix a memory leak in listview.c (found by Smatch).


-------------- next part --------------
>From 4e812f5f73715a593ea1db1d71c53c1812dd44de Mon Sep 17 00:00:00 2001
From: Lionel Debroux <lionel_debroux at yahoo.fr>
Date: Mon, 3 Sep 2007 14:59:55 +0200
Subject: regedit: fix a memory leak in listview.c (found by Smatch).

---
 programs/regedit/listview.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c
index 0e4b52b..8b58eec 100644
--- a/programs/regedit/listview.c
+++ b/programs/regedit/listview.c
@@ -61,7 +61,10 @@ static LPTSTR get_item_text(HWND hwndLV, int item)
 
     curStr = HeapAlloc(GetProcessHeap(), 0, maxLen);
     if (!curStr) return NULL;
-    if (item == 0) return NULL; /* first item is ALWAYS a default */
+    if (item == 0) { /* first item is ALWAYS a default */
+        HeapFree(GetProcessHeap(), 0, curStr);
+        return NULL;
+    }
     do {
         ListView_GetItemText(hwndLV, item, 0, curStr, maxLen);
 	if (_tcslen(curStr) < maxLen - 1) return curStr;
-- 
1.4.4.4



More information about the wine-patches mailing list