From c3821f6c6389e8087a916b6a313d94c39e08abf5 Mon Sep 17 00:00:00 2001 From: Bruno Jesus <00cpxxx@gmail.com> Date: Thu, 26 Apr 2012 23:51:08 -0300 Subject: [PATCH] regedit: Fix item text reading in regedit. --- programs/regedit/listview.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c index bbd5dd649e0..65591165187 100644 --- a/programs/regedit/listview.c +++ b/programs/regedit/listview.c @@ -58,20 +58,17 @@ LPWSTR GetItemText(HWND hwndLV, UINT item) { LPWSTR newStr, curStr; unsigned int maxLen = 128; + if (item == 0) return NULL; /* first item is ALWAYS a default */ curStr = HeapAlloc(GetProcessHeap(), 0, maxLen * sizeof(WCHAR)); if (!curStr) return NULL; - if (item == 0) { /* first item is ALWAYS a default */ - HeapFree(GetProcessHeap(), 0, curStr); - return NULL; - } do { - ListView_GetItemTextW(hwndLV, item, 0, curStr, maxLen * sizeof(WCHAR)); + ListView_GetItemTextW(hwndLV, item, 0, curStr, maxLen); if (lstrlenW(curStr) < maxLen - 1) return curStr; - newStr = HeapReAlloc(GetProcessHeap(), 0, curStr, maxLen * 2 * sizeof(WCHAR)); + maxLen *= 2; + newStr = HeapReAlloc(GetProcessHeap(), 0, curStr, maxLen * sizeof(WCHAR)); if (!newStr) break; curStr = newStr; - maxLen *= 2; } while (TRUE); HeapFree(GetProcessHeap(), 0, curStr); return NULL; -- 2.11.4.GIT