Commit c3821f6c authored by Bruno Jesus's avatar Bruno Jesus Committed by Alexandre Julliard

regedit: Fix item text reading in regedit.

parent 28335fb3
...@@ -58,20 +58,17 @@ LPWSTR GetItemText(HWND hwndLV, UINT item) ...@@ -58,20 +58,17 @@ LPWSTR GetItemText(HWND hwndLV, UINT item)
{ {
LPWSTR newStr, curStr; LPWSTR newStr, curStr;
unsigned int maxLen = 128; unsigned int maxLen = 128;
if (item == 0) return NULL; /* first item is ALWAYS a default */
curStr = HeapAlloc(GetProcessHeap(), 0, maxLen * sizeof(WCHAR)); curStr = HeapAlloc(GetProcessHeap(), 0, maxLen * sizeof(WCHAR));
if (!curStr) return NULL; if (!curStr) return NULL;
if (item == 0) { /* first item is ALWAYS a default */
HeapFree(GetProcessHeap(), 0, curStr);
return NULL;
}
do { do {
ListView_GetItemTextW(hwndLV, item, 0, curStr, maxLen * sizeof(WCHAR)); ListView_GetItemTextW(hwndLV, item, 0, curStr, maxLen);
if (lstrlenW(curStr) < maxLen - 1) return curStr; 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; if (!newStr) break;
curStr = newStr; curStr = newStr;
maxLen *= 2;
} while (TRUE); } while (TRUE);
HeapFree(GetProcessHeap(), 0, curStr); HeapFree(GetProcessHeap(), 0, curStr);
return NULL; return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment