From d60c8a255e3ff5a6c737b12d8cbb6bd500148005 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Wed, 16 Dec 2015 17:02:21 -0500 Subject: [PATCH] Fix optional dereferences --- libraries/chain/db_block.cpp | 7 ++++++- libraries/plugins/market_history/market_history_plugin.cpp | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 3cf91508fe..c09b4ab3fc 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -442,7 +442,12 @@ uint32_t database::push_applied_operation( const operation& op ) void database::set_applied_operation_result( uint32_t op_id, const operation_result& result ) { assert( op_id < _applied_ops.size() ); - _applied_ops[op_id]->result = result; + if( _applied_ops[op_id] ) + _applied_ops[op_id]->result = result; + else + { + elog( "Could not set operation result (head_block_num=${b})", ("b", head_block_num()) ); + } } const vector >& database::get_applied_operations() const diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index ce99a9a98f..b62c415e7e 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -218,7 +218,10 @@ void market_history_plugin_impl::update_market_histories( const signed_block& b graphene::chain::database& db = database(); const vector >& hist = db.get_applied_operations(); for( const optional< operation_history_object >& o_op : hist ) - o_op->op.visit( operation_process_fill_order( _self, b.timestamp ) ); + { + if( o_op.valid() ) + o_op->op.visit( operation_process_fill_order( _self, b.timestamp ) ); + } } } // end namespace detail