Skip to content

Commit

Permalink
Fix a crash in forwarded sender avatars.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston authored and EricKotato committed Sep 26, 2024
1 parent e30c185 commit 0581eb6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Telegram/SourceFiles/history/history_item_components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,19 @@ void HistoryMessageForwarded::create(
? originalSender->name()
: originalHiddenSenderInfo->name)
};
if (originalSender) {
context.session = &originalSender->owner().session();
if (const auto copy = originalSender) {
context.session = &copy->owner().session();
context.customEmojiRepaint = [=] {
originalSender->owner().requestItemRepaint(item);
// It is important to capture here originalSender by value,
// not capture the HistoryMessageForwarded* and read the
// originalSender field, because the components themselves
// get moved from place to place and the captured `this`
// pointer may become invalid, resulting in a crash.
copy->owner().requestItemRepaint(item);
};
phrase = Ui::Text::SingleCustomEmoji(
context.session->data().customEmojiManager().peerUserpicEmojiData(
originalSender,
copy,
st::fwdTextUserpicPadding));
}
if (!originalPostAuthor.isEmpty()) {
Expand Down

0 comments on commit 0581eb6

Please sign in to comment.