fix dereferencing of deleted objects

This commit is contained in:
Daniel Larimer 2015-10-08 14:55:01 -04:00
parent a536d39253
commit be7c0076d0
2 changed files with 7 additions and 7 deletions

View file

@ -339,14 +339,12 @@ bool database::fill_order( const call_order_object& order, const asset& pays, co
}); });
} }
if( collateral_freed )
{
remove( order );
}
assert( pays.asset_id != receives.asset_id ); assert( pays.asset_id != receives.asset_id );
push_applied_operation( fill_order_operation{ order.id, order.borrower, pays, receives, asset(0, pays.asset_id) } ); push_applied_operation( fill_order_operation{ order.id, order.borrower, pays, receives, asset(0, pays.asset_id) } );
if( collateral_freed )
remove( order );
return collateral_freed.valid(); return collateral_freed.valid();
} FC_CAPTURE_AND_RETHROW( (order)(pays)(receives) ) } } FC_CAPTURE_AND_RETHROW( (order)(pays)(receives) ) }

View file

@ -222,16 +222,18 @@ void_result call_order_update_evaluator::do_apply(const call_order_update_operat
// limit orders available that could be used to fill the order. // limit orders available that could be used to fill the order.
if( d.check_call_orders( *_debt_asset, false ) ) if( d.check_call_orders( *_debt_asset, false ) )
{ {
auto call_obj = find_object(call_order_id);
// if we filled at least one call order, we are OK if we totally filled. // if we filled at least one call order, we are OK if we totally filled.
GRAPHENE_ASSERT( GRAPHENE_ASSERT(
!d.find_object( call_order_id ), !d.find_object( call_order_id ),
call_order_update_unfilled_margin_call, call_order_update_unfilled_margin_call,
"Updating call order would trigger a margin call that cannot be fully filled", "Updating call order would trigger a margin call that cannot be fully filled",
("a", ~call_obj->call_price)("b", _bitasset_data->current_feed.settlement_price) ("a", call_obj ? ~call_obj->call_price : "NULL")("b", _bitasset_data->current_feed.settlement_price)
); );
} }
else else
{ {
auto call_obj = find_object(call_order_id);
//edump( (~call_obj->call_price) ("<")( _bitasset_data->current_feed.settlement_price) ); //edump( (~call_obj->call_price) ("<")( _bitasset_data->current_feed.settlement_price) );
// We didn't fill any call orders. This may be because we // We didn't fill any call orders. This may be because we
// aren't in margin call territory, or it may be because there // aren't in margin call territory, or it may be because there
@ -240,7 +242,7 @@ void_result call_order_update_evaluator::do_apply(const call_order_update_operat
~call_obj->call_price < _bitasset_data->current_feed.settlement_price, ~call_obj->call_price < _bitasset_data->current_feed.settlement_price,
call_order_update_unfilled_margin_call, call_order_update_unfilled_margin_call,
"Updating call order would trigger a margin call that cannot be fully filled", "Updating call order would trigger a margin call that cannot be fully filled",
("a", ~call_obj->call_price)("b", _bitasset_data->current_feed.settlement_price) ("a",call_obj ? ~call_obj->call_price : "NULL")("b", _bitasset_data->current_feed.settlement_price)
); );
} }
} }