summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfile.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-11-16 11:36:48 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-11-17 13:00:37 (GMT)
commit6f5fb0be85b1d7cc9f93b615b5034c882e946301 (patch)
treeb18d08550ce8a5b39fb20e3b3ea91afcb45ad3af /src/corelib/io/qfile.cpp
parent1e6180c1de906864d2d6d73a9e18ed67574d4ed8 (diff)
downloadQt-6f5fb0be85b1d7cc9f93b615b5034c882e946301.zip
Qt-6f5fb0be85b1d7cc9f93b615b5034c882e946301.tar.gz
Qt-6f5fb0be85b1d7cc9f93b615b5034c882e946301.tar.bz2
There should only be one write buffer at a time in QFile
To be sure, we should explicitly use the size of that buffer and not the whole QRingBuffer when flushing the data. With this change, we make violations of the one-buffer-rule explicitly fail on flush(), but we avoid corrupting data and reading past the buffer's end. Reviewed-by: Markus Goetz
Diffstat (limited to 'src/corelib/io/qfile.cpp')
-rw-r--r--src/corelib/io/qfile.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index c9b2603..d4077bc 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1339,7 +1339,7 @@ QFile::setPermissions(const QString &fileName, Permissions permissions)
static inline qint64 _qfile_writeData(QAbstractFileEngine *engine, QRingBuffer *buffer)
{
- qint64 ret = engine->write(buffer->readPointer(), buffer->size());
+ qint64 ret = engine->write(buffer->readPointer(), buffer->nextDataBlockSize());
if (ret > 0)
buffer->free(ret);
return ret;