2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Fix possible crash in messages forwarding.

Regression was introduced in 2c1e7bfcb6.
This commit is contained in:
John Preston
2023-03-17 19:24:48 +04:00
parent 2635b35b74
commit f66e6879c2
2 changed files with 11 additions and 6 deletions

View File

@@ -1343,8 +1343,9 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
if (!state->requests.empty()) {
return; // Share clicked already.
}
auto items = history->owner().idsToItems(msgIds);
if (items.empty() || result.empty()) {
const auto items = history->owner().idsToItems(msgIds);
const auto existingIds = history->owner().itemsToIds(items);
if (existingIds.empty() || result.empty()) {
return;
}
@@ -1384,12 +1385,12 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
? Flag::f_drop_media_captions
: Flag(0));
auto mtpMsgIds = QVector<MTPint>();
mtpMsgIds.reserve(msgIds.size());
for (const auto &fullId : msgIds) {
mtpMsgIds.reserve(existingIds.size());
for (const auto &fullId : existingIds) {
mtpMsgIds.push_back(MTP_int(fullId.msg));
}
const auto generateRandom = [&] {
auto result = QVector<MTPlong>(msgIds.size());
auto result = QVector<MTPlong>(existingIds.size());
for (auto &value : result) {
value = base::RandomValue<MTPlong>();
}