aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-12-19 19:46:45 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-12-19 19:46:45 -0500
commitf2424ddeaaa2c70c1673594e7c31effec2ccd1cd (patch)
tree67e97091971083a841bb41314933fd25db3c1c6d /src/model
parentb963028f102ea75622ef792968819b79a68d36bd (diff)
parent8c511722e0a431622db32957f9225cd3c8abe1ca (diff)
downloadmonzero-gui-f2424ddeaaa2c70c1673594e7c31effec2ccd1cd.tar.gz
monzero-gui-f2424ddeaaa2c70c1673594e7c31effec2ccd1cd.tar.xz
monzero-gui-f2424ddeaaa2c70c1673594e7c31effec2ccd1cd.zip
Merge pull request #2627
8c51172 Subaddress: fix use-after-free on accessing stale Wallet API data (xiphon)
Diffstat (limited to 'src/model')
-rw-r--r--src/model/SubaddressModel.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/model/SubaddressModel.cpp b/src/model/SubaddressModel.cpp
index 3b56923e..88f80d94 100644
--- a/src/model/SubaddressModel.cpp
+++ b/src/model/SubaddressModel.cpp
@@ -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;