diff options
author | Jaquee <jaquee.monero@gmail.com> | 2017-10-22 16:21:44 +0200 |
---|---|---|
committer | Jaquee <jaquee.monero@gmail.com> | 2017-10-29 15:26:22 +0100 |
commit | a46c1eed8c5725be47d7e12eedf5f296c08fa2c2 (patch) | |
tree | 936cd16e8dd291af54fb277778527ae269326aa6 /src/wallet/wallet2.cpp | |
parent | Wallet API: default values for account and subaddr index (diff) | |
download | monero-a46c1eed8c5725be47d7e12eedf5f296c08fa2c2.tar.xz |
Wallet2: Don't throw when subaddress label doesn't exist
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r-- | src/wallet/wallet2.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index cc0e9e7e2..34c591613 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -692,20 +692,20 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index) //---------------------------------------------------------------------------------------------------- std::string wallet2::get_subaddress_label(const cryptonote::subaddress_index& index) const { - if (index.major >= m_subaddress_labels.size()) - throw std::runtime_error("index.major is out of bound"); - if (index.minor >= m_subaddress_labels[index.major].size()) - throw std::runtime_error("index.minor is out of bound"); + if (index.major >= m_subaddress_labels.size() || index.minor >= m_subaddress_labels[index.major].size()) + { + MERROR("Subaddress label doesn't exist"); + return ""; + } return m_subaddress_labels[index.major][index.minor]; } //---------------------------------------------------------------------------------------------------- void wallet2::set_subaddress_label(const cryptonote::subaddress_index& index, const std::string &label) { - if (index.major >= m_subaddress_labels.size()) - throw std::runtime_error("index.major is out of bound"); - if (index.minor >= m_subaddress_labels[index.major].size()) - throw std::runtime_error("index.minor is out of bound"); - m_subaddress_labels[index.major][index.minor] = label; + if (index.major >= m_subaddress_labels.size() || index.minor >= m_subaddress_labels[index.major].size()) + MERROR("Subaddress index is out of bounds. Failed to set subaddress label."); + else + m_subaddress_labels[index.major][index.minor] = label; } //---------------------------------------------------------------------------------------------------- /*! |