diff options
author | Chris Kawano <808christian@gmail.com> | 2011-03-01 12:12:37 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-03-01 12:20:33 (GMT) |
commit | 17a4f332f0d416af842145f0ebc7f2ebe7f33527 (patch) | |
tree | 822b21b8f3036c28000fc90af54899dc6c0e639b /src/corelib/io/qtextstream.cpp | |
parent | cb042e8dcc836a89919d7c048698154f2c423307 (diff) | |
download | Qt-17a4f332f0d416af842145f0ebc7f2ebe7f33527.zip Qt-17a4f332f0d416af842145f0ebc7f2ebe7f33527.tar.gz Qt-17a4f332f0d416af842145f0ebc7f2ebe7f33527.tar.bz2 |
Fix QTextStream::pos() causes buffer offset issues on large text files.
When reading large files that are greater in size than the
TEXTSTREAM_BUFFERSIZE buffer, calling pos() caused erroneous buffer
positioning. The cause of this was QTextStreamPrivate::readBufferOffset
value being updated, but QTextStreamPrivate::readConverterSavedStateOffset
was not. Usually, if pos() is called, it is called multiple times. Since
QTextStreamPrivate::readConverterSavedStateOffset was never reset,
QTextStreamPrivate::readBufferOffset would accumulate the wrong position
and QTextStreamPrivate::consume() will 'discard' the wrong number of
bytes from the buffer.
Task-number: QTBUG-9814
Merge-request: 2569
Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src/corelib/io/qtextstream.cpp')
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index b630502..a5837cb 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -1264,6 +1264,7 @@ qint64 QTextStream::pos() const return qint64(-1); } thatd->readBufferOffset = oldReadBufferOffset; + thatd->readConverterSavedStateOffset = 0; // Return the device position. return d->device->pos(); |