diff options
author | George Hazan <george.hazan@gmail.com> | 2024-05-19 21:49:51 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-05-19 21:49:51 +0300 |
commit | 44c185328ce246e07b7f0ac2f762bb96f3b387df (patch) | |
tree | 390f96ae375753baf07aaac599ba5744cf6ad66f /plugins/NewStory | |
parent | 912e59a43a47536a0f6609d1b1bfe2a4253746cd (diff) |
fixes #4432 (NewStory: падение при очистке большой истории)
Diffstat (limited to 'plugins/NewStory')
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
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));
+ }
}
|