Fix crash when poll answer has fewer selections than possible

BUG: 511909
This commit is contained in:
Tobias Fella
2025-11-11 16:36:25 +01:00
committed by Tobias Fella
parent fe734206df
commit c539dfc352

View File

@@ -121,7 +121,9 @@ void PollHandler::handleResponse(const Quotient::PollResponseEvent *event)
return;
}
m_selections[event->senderId()] = event->selections().size() > 0 ? event->selections().first(pollStartEvent->maxSelections()) : event->selections();
m_selections[event->senderId()] = event->selections().size() > 0
? event->selections().first(std::min(pollStartEvent->maxSelections(), (int)event->selections().size()))
: event->selections();
if (m_selections.contains(event->senderId()) && m_selections[event->senderId()].isEmpty()) {
m_selections.remove(event->senderId());
}