mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-03 15:57:25 -04:00
Merge pull request #2627
8c51172 Subaddress: fix use-after-free on accessing stale Wallet API data (xiphon)
This commit is contained in:
@@ -60,18 +60,23 @@ QVariant SubaddressModel::data(const QModelIndex &index, int role) const
|
||||
if (!index.isValid() || index.row() < 0 || (unsigned)index.row() >= m_subaddress->count())
|
||||
return {};
|
||||
|
||||
Monero::SubaddressRow * sr = m_subaddress->getRow(index.row());
|
||||
if (!sr)
|
||||
return {};
|
||||
QVariant result;
|
||||
|
||||
QVariant result = "";
|
||||
switch (role) {
|
||||
case SubaddressAddressRole:
|
||||
result = QString::fromStdString(sr->getAddress());
|
||||
break;
|
||||
case SubaddressLabelRole:
|
||||
result = index.row() == 0 ? tr("Primary address") : QString::fromStdString(sr->getLabel());
|
||||
break;
|
||||
bool found = m_subaddress->getRow(index.row(), [&index, &result, &role](const Monero::SubaddressRow &subaddress) {
|
||||
switch (role) {
|
||||
case SubaddressAddressRole:
|
||||
result = QString::fromStdString(subaddress.getAddress());
|
||||
break;
|
||||
case SubaddressLabelRole:
|
||||
result = index.row() == 0 ? tr("Primary address") : QString::fromStdString(subaddress.getLabel());
|
||||
break;
|
||||
default:
|
||||
qCritical() << "Unimplemented role" << role;
|
||||
}
|
||||
});
|
||||
if (!found)
|
||||
{
|
||||
qCritical("%s: internal error: invalid index %d", __FUNCTION__, index.row());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user