From 555d90b2c95f3d624bbd48daed2ce6268af656e9 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 2 Sep 2015 18:16:26 +0100 Subject: [PATCH 1/3] berkeleydb: fix delete/free mismatch Despite being C++, the stats object is allocated by the underlying C layer using malloc(3). --- src/blockchain_db/berkeleydb/db_bdb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index a990d7aaf..7f3f32628 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -726,12 +726,12 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags) // to zero (0) for reliability. m_blocks->stat(NULL, &stats, 0); m_height = stats->bt_nkeys; - delete stats; + free(stats); // see above comment about DB_FAST_STAT m_output_indices->stat(NULL, &stats, 0); m_num_outputs = stats->bt_nkeys; - delete stats; + free(stats); // run checkpoint thread m_run_checkpoint = true; From b0a98b2cecdc7f3825db7409e6e0147147c3ddb8 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 2 Sep 2015 18:50:30 +0100 Subject: [PATCH 2/3] unit_tests: initialize enough to silence valgrind --- tests/unit_tests/serialization.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit_tests/serialization.cpp b/tests/unit_tests/serialization.cpp index d4bb0e2fa..4e00683ad 100644 --- a/tests/unit_tests/serialization.cpp +++ b/tests/unit_tests/serialization.cpp @@ -394,6 +394,8 @@ TEST(Serialization, serializes_transacion_signatures_correctly) // Not enough signature vectors for all inputs txin_to_key txin_to_key1; + txin_to_key1.amount = 1000000000000; + memset(txin_to_key1.k_image.data,0,32); txin_to_key1.key_offsets.resize(2); tx.vin.clear(); tx.vin.push_back(txin_to_key1); From 93aadbd1e4e3127f7799dff2ee2a0e9c027b70a7 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 2 Sep 2015 19:05:02 +0100 Subject: [PATCH 3/3] unit_tests: initialize a field to silence a valgrind report A memory chunk is split in two, and the concatenation of the two parts compared to the original, triggering a comparison with uninitialized (with a copy of itself, but valgrind does not realize that). --- tests/unit_tests/epee_levin_protocol_handler_async.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp index 096133105..29ee9e87d 100644 --- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp +++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp @@ -242,6 +242,7 @@ namespace m_req_head.m_cb = m_in_data.size(); m_req_head.m_have_to_return_data = true; m_req_head.m_command = expected_command; + m_req_head.m_return_code = 0; m_req_head.m_flags = LEVIN_PACKET_REQUEST; m_req_head.m_protocol_version = LEVIN_PROTOCOL_VER_1;