From 2633949d5b613cd6bebcaaf9090c6ebc21272d72 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 30 Jun 2016 11:07:11 -0700 Subject: [PATCH] Fix access to obsolete reference in PathRequest (RIPD-1219): * Don't access jvArray if newStatus is replaced * Remove iLastLevel and use just iLevel --- src/ripple/app/paths/PathRequest.cpp | 20 ++++++++++++-------- src/ripple/app/paths/PathRequest.h | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp index b98c72b80..dd0597437 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/ripple/app/paths/PathRequest.cpp @@ -52,7 +52,7 @@ PathRequest::PathRequest ( , jvStatus (Json::objectValue) , mLastIndex (0) , mInProgress (false) - , iLastLevel (0) + , iLevel (0) , bLastSuccess (false) , iIdentifier (id) , created_ (std::chrono::steady_clock::now()) @@ -76,7 +76,7 @@ PathRequest::PathRequest ( , jvStatus (Json::objectValue) , mLastIndex (0) , mInProgress (false) - , iLastLevel (0) + , iLevel (0) , bLastSuccess (false) , iIdentifier (id) , created_ (std::chrono::steady_clock::now()) @@ -651,7 +651,6 @@ Json::Value PathRequest::doUpdate( if (jvId) newStatus["id"] = jvId; - int iLevel = iLastLevel; bool loaded = app_.getFeeTrack().isLoadedLocal(); if (iLevel == 0) @@ -688,12 +687,17 @@ Json::Value PathRequest::doUpdate( JLOG(m_journal.debug()) << iIdentifier << " processing at level " << iLevel; - Json::Value& jvArray = (newStatus[jss::alternatives] = Json::arrayValue); - if (! findPaths(cache, iLevel, jvArray)) + Json::Value jvArray = Json::arrayValue; + if (findPaths(cache, iLevel, jvArray)) + { + bLastSuccess = jvArray.size() != 0; + newStatus[jss::alternatives] = std::move (jvArray); + } + else + { + bLastSuccess = false; newStatus = rpcError(rpcINTERNAL); - - bLastSuccess = jvArray.size(); - iLastLevel = iLevel; + } if (fast && quick_reply_ == steady_clock::time_point{}) { diff --git a/src/ripple/app/paths/PathRequest.h b/src/ripple/app/paths/PathRequest.h index edd22d296..372cbe567 100644 --- a/src/ripple/app/paths/PathRequest.h +++ b/src/ripple/app/paths/PathRequest.h @@ -141,7 +141,7 @@ private: LedgerIndex mLastIndex; bool mInProgress; - int iLastLevel; + int iLevel; bool bLastSuccess; int iIdentifier;