Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit 5e00980

Browse files
committed
SparseFieldIO: Fix read past end of array.
1 parent 071129f commit 5e00980

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/SparseFieldIO.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ class WriteBlockOp
221221
size_t blockIdx;
222222
{
223223
boost::mutex::scoped_lock lock(m_state.compressMutex);
224-
blockIdx = m_state.nextBlockToCompress;
224+
blockIdx = m_state.nextBlockToCompress++;
225225
// Step counter to next
226226
while (m_state.nextBlockToCompress < m_state.numBlocks) {
227-
m_state.nextBlockToCompress++;
228227
if (m_state.blocks[m_state.nextBlockToCompress].isAllocated) {
229228
break;
230229
}
230+
m_state.nextBlockToCompress++;
231231
}
232232
}
233233
// Loop over blocks until we run out
@@ -261,24 +261,25 @@ class WriteBlockOp
261261
// Do the writing
262262
m_state.data.addData(cmpLen, &m_cache[0]);
263263
// Let next block write
264+
m_state.nextBlockToWrite++;
264265
while (m_state.nextBlockToWrite < m_state.numBlocks){
265266
// Increment to next
266-
m_state.nextBlockToWrite++;
267267
if (m_state.blocks[m_state.nextBlockToWrite].isAllocated) {
268268
break;
269269
}
270+
m_state.nextBlockToWrite++;
270271
}
271272
}
272273
// Get next block idx
273274
{
274275
boost::mutex::scoped_lock lock(m_state.compressMutex);
275-
blockIdx = m_state.nextBlockToCompress;
276+
blockIdx = m_state.nextBlockToCompress++;
276277
// Step counter to next
277278
while (m_state.nextBlockToCompress < m_state.numBlocks) {
278-
m_state.nextBlockToCompress++;
279279
if (m_state.blocks[m_state.nextBlockToCompress].isAllocated) {
280280
break;
281281
}
282+
m_state.nextBlockToCompress++;
282283
}
283284
}
284285
}

0 commit comments

Comments
 (0)