From 59f7eb76bda7b251db30967a514712892ddada4e Mon Sep 17 00:00:00 2001 From: u130b8 <115743848+u130b8@users.noreply.github.com> Date: Fri, 13 Oct 2023 13:28:11 +0300 Subject: [PATCH] update pGroup after realloc --- progmgr/group.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/progmgr/group.c b/progmgr/group.c index f771a32..4717aca 100644 --- a/progmgr/group.c +++ b/progmgr/group.c @@ -266,8 +266,11 @@ PITEM CreateItem(_In_ HWND hWndGroup, _In_ PITEM pi) if (_msize(pGroup) != CalculateGroupMemory(pGroup, 1)) { // 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); + } } // add the item