Skip to content

Commit c9ed9bf

Browse files
committed
prevent wrong memory accessing
1 parent 0904feb commit c9ed9bf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

RESTAPI/bobAPI.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ std::string bobGetLog(uint16_t epoch, int64_t start, int64_t end)
203203
logTxOrder = lr.sort();
204204
// scan to find the first cursor
205205
logTxOrderIndex = lr.scanTxId(logTxOrder, 0, log.getLogId());
206+
if (logTxOrderIndex == -1)
207+
{
208+
result.push_back(']');
209+
return result;
210+
}
206211
int txIndex = logTxOrder[logTxOrderIndex];
207212

208213
if (log.getTick() != gInitialTick && txIndex < NUMBER_OF_TRANSACTIONS_PER_TICK)
@@ -246,11 +251,6 @@ std::string bobGetLog(uint16_t epoch, int64_t start, int64_t end)
246251
}
247252
}
248253

249-
if (logTxOrderIndex == -1)
250-
{
251-
result.push_back(']');
252-
return result;
253-
}
254254
txIndex = logTxOrder[logTxOrderIndex];
255255
auto s = lr.fromLogId[txIndex];
256256
auto e = s + lr.length[txIndex] - 1;

0 commit comments

Comments
 (0)