diff --git a/Detectors/TOF/compression/src/Compressor.cxx b/Detectors/TOF/compression/src/Compressor.cxx index 6d08a056852ac..6000e6e9d5185 100644 --- a/Detectors/TOF/compression/src/Compressor.cxx +++ b/Detectors/TOF/compression/src/Compressor.cxx @@ -251,6 +251,17 @@ bool Compressor::processHBF() mErrorCounter++; } + // before to move to RDH close check we are not already out of buffer (it is the last chance to call rewind and not to store RDH open) + if (mEncoderPointer >= mEncoderPointerMax) { + LOG(error) << "link = " << rdh->feeId << ": beyond the buffer size mEncoderPointer in RDH open = " << mEncoderPointer << " >= " + << "mEncoderPointerMax = " << mEncoderPointerMax; + long byteOutOfBuffer = mEncoderPointer + rdh->headerSize - mEncoderPointerMax; + LOG(error) << "byte out of buffer = " << byteOutOfBuffer; + + encoderRewind(); + return true; + } + /** copy RDH close to encoder buffer **/ /** CAREFUL WITH THE PAGE COUNTER **/ if (mEncoderPointer + rdh->headerSize >= mEncoderPointerMax) {