From e64eb8a1187e0d869bf8850559518749c13a3340 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 30 Jun 2017 22:32:13 +0200 Subject: [PATCH] Only load extra byte in the CSV parser when there's more data available --- src/csvparser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csvparser.cpp b/src/csvparser.cpp index c614ed4f..69907a63 100644 --- a/src/csvparser.cpp +++ b/src/csvparser.cpp @@ -69,7 +69,7 @@ bool CSVParser::parse(QTextStream& stream, qint64 nMaxRecords) // because of the m_nBufferSize boundary. But this means that the following check won't work properly because we can't check the // next byte when we really should be able to do so because there's more data coming. To fix this we'll check for this particular // case and, if this is what's happening, we'll just load an extra byte. - if(nit == sBuffer.end()) + if(nit == sBuffer.end() && !stream.atEnd()) { // Load one more byte sBuffer.append(stream.read(1)); @@ -137,7 +137,7 @@ bool CSVParser::parse(QTextStream& stream, qint64 nMaxRecords) QString::iterator nit = it + 1; // See above for details on this. - if(nit == sBuffer.end()) + if(nit == sBuffer.end() && !stream.atEnd()) { sBuffer.append(stream.read(1)); it = sBuffer.end() - 2;