wallet2: Missing underflow check on low heights

Lack of it results in `m_refresh_from_block_height` being < 0 (18446744...) on low heights, which blocks `process_new_blockchain_entry` and never process coins on heights less than blocks_per_month.
Follow-up to #2258
This commit is contained in:
landergate 2017-09-27 14:17:48 +03:00 committed by moneromooo-monero
parent 15b0ff2c32
commit 44afa6de07
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -2255,7 +2255,7 @@ crypto::secret_key wallet2::generate(const std::string& wallet_, const std::stri
// Set blockchain height calculated from current date/time // Set blockchain height calculated from current date/time
uint64_t approx_blockchain_height = get_approximate_blockchain_height(); uint64_t approx_blockchain_height = get_approximate_blockchain_height();
if(approx_blockchain_height > 0) { if(approx_blockchain_height > 0) {
m_refresh_from_block_height = approx_blockchain_height - blocks_per_month; m_refresh_from_block_height = approx_blockchain_height >= blocks_per_month ? approx_blockchain_height - blocks_per_month : 0;
} }
} }
bool r = store_keys(m_keys_file, password, false); bool r = store_keys(m_keys_file, password, false);