Skip to content

Commit

Permalink
Fix segfault when non intialized ITF was destructed (hyperledger-iroh…
Browse files Browse the repository at this point in the history
…a#1353)

Signed-off-by: Igor Egorov <[email protected]>
  • Loading branch information
igor-egorov authored May 18, 2018
1 parent 5c0631a commit f030fcc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ namespace integration_framework {

void IntegrationTestFramework::done() {
log_->info("done");
iroha_instance_->instance_->storage->dropStorage();
if (iroha_instance_->instance_ and iroha_instance_->instance_->storage) {
iroha_instance_->instance_->storage->dropStorage();
}
}
} // namespace integration_framework
10 changes: 10 additions & 0 deletions test/regression/regression_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,13 @@ TEST(RegressionTest, DoubleCallOfDone) {
itf.setInitialState(kAdminKeypair).done();
itf.done();
}

/**
* @given non initialized ITF instance
* @when done method is called inside destructor
* @then no exceptions are risen
*/
TEST(RegressionTest, DestructionOfNonInitializedItf) {
integration_framework::IntegrationTestFramework itf(
1, [](auto &itf) { itf.done(); });
}

0 comments on commit f030fcc

Please sign in to comment.