Merge pull request #38 from u130b8/fix-realloc

update pGroup after realloc
This commit is contained in:
freedom
2023-10-13 08:21:28 -06:00
committed by GitHub

View File

@@ -266,9 +266,12 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi)
if (_msize(pGroup) != CalculateGroupMemory(pGroup, 1)) if (_msize(pGroup) != CalculateGroupMemory(pGroup, 1))
{ {
// if we reallocate memory then send the new pointer in // if we reallocate memory then send the new pointer in
if (realloc(pGroup, CalculateGroupMemory(pGroup, 1)) != NULL) PGROUP pNewGroup = realloc(pGroup, CalculateGroupMemory(pGroup, 1));
if (pNewGroup != NULL) {
pGroup = pNewGroup;
SetWindowLongPtr(hWndGroup, GWLP_USERDATA, (LONG_PTR)pGroup); SetWindowLongPtr(hWndGroup, GWLP_USERDATA, (LONG_PTR)pGroup);
} }
}
// add the item // add the item
pItem = &pGroup->pItemArray + pGroup->cItemArray; pItem = &pGroup->pItemArray + pGroup->cItemArray;