From 6f5fb0be85b1d7cc9f93b615b5034c882e946301 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 16 Nov 2009 12:36:48 +0100 Subject: [PATCH] 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 --- src/corelib/io/qfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index c9b26032ea..d4077bcb23 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; -- 2.11.4.GIT