diff options
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 12 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index d625e5a07..9555318a5 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -130,13 +130,16 @@ private: template<> struct MDB_val_copy<const char*>: public MDB_val { - MDB_val_copy(const char *s) : - data(strdup(s)) + MDB_val_copy(const char *s): + size(strlen(s)+1), // include the NUL, makes it easier for compares + data(new char[size]) { - mv_size = strlen(s) + 1; // include the NUL, makes it easier for compares + mv_size = size; mv_data = data.get(); + memcpy(mv_data, s, size); } private: + size_t size; std::unique_ptr<char[]> data; }; @@ -923,6 +926,8 @@ BlockchainLMDB::~BlockchainLMDB() // batch transaction shouldn't be active at this point. If it is, consider it aborted. if (m_batch_active) batch_abort(); + if (m_open) + close(); } BlockchainLMDB::BlockchainLMDB(bool batch_transactions) @@ -1153,6 +1158,7 @@ void BlockchainLMDB::close() // FIXME: not yet thread safe!!! Use with care. mdb_env_close(m_env); + m_open = false; } void BlockchainLMDB::sync() diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index feb31f2fc..141a42f49 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2109,6 +2109,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc if(have_tx_keyimg_as_spent(in_to_key.k_image)) { LOG_PRINT_L1("Key image already spent in blockchain: " << epee::string_tools::pod_to_hex(in_to_key.k_image)); + KILL_IOSERVICE(); return false; } @@ -2122,6 +2123,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc if(!itk->second) { LOG_PRINT_L1("Failed ring signature for tx " << get_transaction_hash(tx) << " vin key with k_image: " << in_to_key.k_image << " sig_index: " << sig_index); + KILL_IOSERVICE(); return false; } |