diff --git a/lib/session/MeasurementSession.h b/lib/session/MeasurementSession.h index 0924662..0cc15fa 100644 --- a/lib/session/MeasurementSession.h +++ b/lib/session/MeasurementSession.h @@ -92,7 +92,10 @@ private: "serializeChunk: invalid startIdx" ); if( startIdx >= currentChunk->getStartIndex() ) { - encoder.sendArrayPartialContents( currentChunk->getDataPointer(), currentChunk->numMeasurements() ); + const auto localStartIdx = startIdx - currentChunk->getStartIndex(); + const auto numElements = currentChunk->numMeasurements() - localStartIdx; + assert(numElements <= currentChunk->numMeasurements(), "Internal problem in serializeChunk"); + encoder.sendArrayPartialContents( currentChunk->getDataPointer() + localStartIdx, numElements ); return currentChunk->getStartIndex() + currentChunk->numMeasurements(); } else if( startIdx >= otherChunk->getStartIndex() && otherChunkFilled() ) { encoder.sendArrayPartialContents( otherChunk->getDataPointer(), otherChunk->numMeasurements() );