From 10cb83c88396e1cf57b552c5de081e8befa7b47f Mon Sep 17 00:00:00 2001 From: morgane-fauvet <morgane.fauvet@mensiatech.com> Date: Thu, 30 Nov 2017 11:45:31 +0100 Subject: [PATCH] [OV Plugin File IO] Fix reader of feature vector: crash when reading feature vector, and crash when reading a file containing only a reader. Tracker reference: [CORE-1169] (https://jira.mensiatech.com/browse/CORE-1169) --- modules/csv/src/ovCCSV.cpp | 1 - .../csv/ovpCBoxAlgorithmOVCSVFileReader.cpp | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/modules/csv/src/ovCCSV.cpp b/modules/csv/src/ovCCSV.cpp index 8d3443dfa..e5ade4a58 100755 --- a/modules/csv/src/ovCCSV.cpp +++ b/modules/csv/src/ovCCSV.cpp @@ -585,7 +585,6 @@ bool CCSVHandler::readSamplesAndEventsFromFile(size_t chunksToRead, std::vector< } chunks.clear(); - chunks.reserve(chunksToRead); // Calculate the size of the matrix depending of the stream type size_t matrixSize = static_cast<size_t>(m_SampleCountPerBuffer); diff --git a/plugins/processing/file-io/src/box-algorithms/csv/ovpCBoxAlgorithmOVCSVFileReader.cpp b/plugins/processing/file-io/src/box-algorithms/csv/ovpCBoxAlgorithmOVCSVFileReader.cpp index 9f22d6e3f..c6a2d1a01 100755 --- a/plugins/processing/file-io/src/box-algorithms/csv/ovpCBoxAlgorithmOVCSVFileReader.cpp +++ b/plugins/processing/file-io/src/box-algorithms/csv/ovpCBoxAlgorithmOVCSVFileReader.cpp @@ -231,9 +231,9 @@ bool CBoxAlgorithmOVCSVFileReader::process(void) "Failed to set dimension label", ErrorType::Internal); } - } - m_AlgorithmEncoder.getInputSamplingRate() = m_SamplingRate; + m_AlgorithmEncoder.getInputSamplingRate() = m_SamplingRate; + } OV_ERROR_UNLESS_KRF(m_AlgorithmEncoder.encodeHeader(), "Failed to encode signal header", @@ -269,16 +269,16 @@ bool CBoxAlgorithmOVCSVFileReader::process(void) } while (!m_SavedChunks.empty() && m_SavedChunks.back().startTime < currentTime && m_ReaderLib->hasDataToRead()); } - double chunkStartTime = m_SavedChunks.cbegin()->startTime; - double chunkEndTime = m_SavedChunks.back().endTime; - - // send stimulations chunk even if there is no stimulations, chunks have to be continued - OV_ERROR_UNLESS_KRF(this->processStimulation(chunkStartTime, chunkEndTime), - "Error during stimulation process", - ErrorType::Internal); - if (!m_SavedChunks.empty()) { + double chunkStartTime = m_SavedChunks.cbegin()->startTime; + double chunkEndTime = m_SavedChunks.back().endTime; + + // send stimulations chunk even if there is no stimulations, chunks have to be continued + OV_ERROR_UNLESS_KRF(this->processStimulation(chunkStartTime, chunkEndTime), + "Error during stimulation process", + ErrorType::Internal); + uint32_t chunksToRemove = 0; for (const SMatrixChunk& chunk : m_SavedChunks) -- GitLab