Fix access to obsolete reference in PathRequest (RIPD-1219):

* Don't access jvArray if newStatus is replaced
* Remove iLastLevel and use just iLevel
This commit is contained in:
JoelKatz
2016-06-30 11:07:11 -07:00
committed by seelabs
parent 16a38f3979
commit 2633949d5b
2 changed files with 13 additions and 9 deletions

View File

@@ -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{})
{

View File

@@ -141,7 +141,7 @@ private:
LedgerIndex mLastIndex;
bool mInProgress;
int iLastLevel;
int iLevel;
bool bLastSuccess;
int iIdentifier;