From 210c7b9cdc66ff5f474056b5652ea7fe69bb59a3 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Sun, 17 May 2020 15:38:14 +0200 Subject: [PATCH] Bugfix in sending of measurement data --- lib/session/MeasurementSession.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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() );