regedit: Store the data from a listview subitem in a valid memory address.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2017-07-28 13:22:27 +00:00 committed by Alexandre Julliard
parent 793ddc992c
commit 5d9a4c4dbd
2 changed files with 12 additions and 7 deletions

View file

@ -397,6 +397,7 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
LINE_INFO *info = (LINE_INFO *)nmlv->lParam;
heap_free(info->name);
heap_free(info->val);
heap_free(info);
break;
}

View file

@ -152,23 +152,27 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz
int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWORD dwCount, int pos)
{
LINE_INFO *linfo;
LVITEMW item = { 0 };
LINE_INFO* linfo;
int index;
linfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINE_INFO) + dwCount);
linfo = heap_xalloc(sizeof(LINE_INFO));
linfo->dwValType = dwValType;
linfo->val_len = dwCount;
CopyMemory(&linfo[1], ValBuf, dwCount);
if (Name)
{
linfo->name = heap_xalloc((lstrlenW(Name) + 1) * sizeof(WCHAR));
lstrcpyW(linfo->name, Name);
} else
{
linfo->name = NULL;
}
else linfo->name = NULL;
if (ValBuf && dwCount)
{
linfo->val = heap_xalloc(dwCount);
memcpy(&linfo->val, ValBuf, dwCount);
}
else linfo->val = NULL;
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
item.iItem = (pos == -1) ? SendMessageW(hwndLV, LVM_GETITEMCOUNT, 0, 0) : pos;