From 1d12e7a8b7fe389766b92968a513e84fc0170435 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 8 Feb 2013 22:11:07 -0800 Subject: [PATCH] Don't crash if a node is deleted. --- src/cpp/ripple/OrderBookDB.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/cpp/ripple/OrderBookDB.cpp b/src/cpp/ripple/OrderBookDB.cpp index 101cf3c3ad..93da712b76 100644 --- a/src/cpp/ripple/OrderBookDB.cpp +++ b/src/cpp/ripple/OrderBookDB.cpp @@ -182,20 +182,23 @@ void OrderBookDB::processTxn(const SerializedTransaction& stTxn, TER terResult,T field=&sfNewFields; } - const STObject* previous = dynamic_cast(node.peekAtPField(*field)); - if(previous) + if (field) { - STAmount takerGets = previous->getFieldAmount(sfTakerGets); - uint160 currencyOut=takerGets.getCurrency(); - uint160 issuerOut=takerGets.getIssuer(); + const STObject* previous = dynamic_cast(node.peekAtPField(*field)); + if(previous) + { + STAmount takerGets = previous->getFieldAmount(sfTakerGets); + uint160 currencyOut=takerGets.getCurrency(); + uint160 issuerOut=takerGets.getIssuer(); - STAmount takerPays = previous->getFieldAmount(sfTakerPays); - uint160 currencyIn=takerPays.getCurrency(); - uint160 issuerIn=takerPays.getIssuer(); + STAmount takerPays = previous->getFieldAmount(sfTakerPays); + uint160 currencyIn=takerPays.getCurrency(); + uint160 issuerIn=takerPays.getIssuer(); - // determine the OrderBook - BookListeners::pointer book=getBookListeners(currencyIn,currencyOut,issuerIn,issuerOut); - if(book) book->publish(jvObj); + // determine the OrderBook + BookListeners::pointer book=getBookListeners(currencyIn,currencyOut,issuerIn,issuerOut); + if(book) book->publish(jvObj); + } } } }catch(...)