From 44c185328ce246e07b7f0ac2f762bb96f3b387df Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 19 May 2024 21:49:51 +0300 Subject: =?UTF-8?q?fixes=20#4432=20(NewStory:=20=D0=BF=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B8=20=D0=BE=D1=87=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BA=D0=B5=20=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=B8=D1=81=D1=82=D0=BE=D1=80=D0=B8=D0=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_array.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'plugins/NewStory/src') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index d73e137b64..48a06f4043 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -76,10 +76,12 @@ ItemData::ItemData() ItemData::~ItemData() { - mir_free(qtext); - mir_free(wtext); - if (dbe.szReplyId) - mir_free((char*)dbe.szReplyId); + replaceStrW(qtext, 0); + replaceStrW(wtext, 0); + if (dbe.szReplyId) { + mir_free((char *)dbe.szReplyId); + dbe.szReplyId = 0; + } } ///////////////////////////////////////////////////////////////////////////////////////// @@ -725,7 +727,8 @@ void HistoryArray::remove(int id) if (offset != HIST_BLOCK_SIZE - 1) memmove(&pPage.data[offset], &pPage.data[offset+1], sizeof(ItemData) * (HIST_BLOCK_SIZE - 1 - offset)); - for (int i = pageNo + 1; i < pages.getCount(); i++) { + int nPages = pages.getCount()-1; + for (int i = pageNo + 1; i <= nPages; i++) { auto &prev = pages[i - 1], &curr = pages[i]; memcpy(&prev.data[HIST_BLOCK_SIZE - 1], curr.data, sizeof(ItemData)); memmove(&curr.data, &curr.data[1], sizeof(ItemData) * (HIST_BLOCK_SIZE - 1)); @@ -733,8 +736,11 @@ void HistoryArray::remove(int id) } if (iLastPageCounter == 1) { - pages.remove(pages.getCount() - 1); + pages.remove(nPages); iLastPageCounter = HIST_BLOCK_SIZE; } - else iLastPageCounter--; + else { + iLastPageCounter--; + memset(&pages[nPages].data[iLastPageCounter], 0, sizeof(ItemData)); + } } -- cgit v1.2.3