Fixing crash when importing corrupt legacy wallet files.

This commit is contained in:
clemahieu 2016-04-21 00:28:34 -05:00
commit 49d773b9a2
2 changed files with 17 additions and 1 deletions

View file

@ -588,6 +588,15 @@ TEST (wallet_store, fail_import_bad_password)
ASSERT_TRUE (error);
}
TEST (wallet_store, fail_import_corrupt)
{
rai::system system (24000, 2);
auto wallet1 (system.wallet (1));
std::string json;
auto error (wallet1->import (json, "1"));
ASSERT_TRUE (error);
}
// Test arbitrary work can be generated
TEST (wallet, empty_work)
{

View file

@ -405,7 +405,14 @@ environment (transaction_a.environment)
assert (mdb_get (transaction_a, handle, version_special.val (), &junk) == MDB_NOTFOUND);
boost::property_tree::ptree wallet_l;
std::stringstream istream (json_a);
boost::property_tree::read_json (istream, wallet_l);
try
{
boost::property_tree::read_json (istream, wallet_l);
}
catch (...)
{
init_a = true;
}
for (auto i (wallet_l.begin ()), n (wallet_l.end ()); i != n; ++i)
{
rai::uint256_union key;