Skip to content

Commit

Permalink
Fix several possible crashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jan 18, 2024
1 parent f53b64b commit e4ca8ae
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
20 changes: 17 additions & 3 deletions Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,23 @@ not_null<Ui::SlideWrap<>*> Controller::addRequestedListBlock(
lt_count_decimal,
std::move(requestedCount)));

const auto delegate = container->lifetime().make_state<
PeerListContentDelegateSimple
>();
class Delegate final : public PeerListContentDelegateSimple {
public:
explicit Delegate(std::shared_ptr<Main::SessionShow> show)
: _show(std::move(show)) {
}

std::shared_ptr<Main::SessionShow> peerListUiShow() override {
return _show;
}

private:
const std::shared_ptr<Main::SessionShow> _show;

};
const auto delegate = container->lifetime().make_state<Delegate>(
this->delegate()->peerListUiShow());

const auto controller = container->lifetime().make_state<
Controller
>(_peer, _data.current().admin, _data.value(), Role::Requested);
Expand Down
6 changes: 4 additions & 2 deletions Telegram/SourceFiles/boxes/share_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,16 +936,18 @@ void ShareBox::Inner::loadProfilePhotos() {
const auto from = std::max(yFrom / _rowHeight, 0);
const auto to = std::max((yTo / _rowHeight) + 1, from);

const auto ffrom = from;
const auto fto = std::min(to, int(_filtered.size()));
const auto ffrom = std::min(from, fto);
for (auto i = ffrom; i != fto; ++i) {
preloadUserpic(_filtered[i]->entry());
}

const auto ufrom = std::max(from - int(_filtered.size()), 0);
const auto uto = std::min(
to - int(_filtered.size()),
int(d_byUsernameFiltered.size()));
const auto ufrom = std::min(
std::max(from - int(_filtered.size()), 0),
uto);
for (auto i = ufrom; i != uto; ++i) {
preloadUserpic(d_byUsernameFiltered[i]->history);
}
Expand Down
2 changes: 1 addition & 1 deletion Telegram/lib_ui

0 comments on commit e4ca8ae

Please sign in to comment.