Skip to content

Commit fc8a95a

Browse files
committed
fix: add bounds checking and fix off-by-one in qt/proposalmodel.cpp
1 parent affa4a9 commit fc8a95a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/qt/proposalmodel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,16 @@ void ProposalModel::setVotingParams(int newAbsVoteReq)
359359
this->nAbsVoteReq = newAbsVoteReq;
360360
// Changing either of the voting params may change the voting status
361361
// column. Emit signal to force recalculation.
362-
Q_EMIT dataChanged(createIndex(0, Column::VOTING_STATUS), createIndex(rowCount(), Column::VOTING_STATUS));
362+
Q_EMIT dataChanged(createIndex(0, Column::VOTING_STATUS), createIndex(rowCount() - 1, Column::VOTING_STATUS));
363363
}
364364
}
365365

366366
const Proposal* ProposalModel::getProposalAt(const QModelIndex& index) const
367367
{
368-
return m_data[index.row()];
368+
if (index.isValid() && index.row() == std::clamp(index.row(), 0, m_data.count())) {
369+
return m_data[index.row()];
370+
}
371+
return nullptr;
369372
}
370373

371374
void ProposalModel::setDisplayUnit(BitcoinUnit display_unit) { this->m_display_unit = display_unit; }

0 commit comments

Comments
 (0)