diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-07-20 16:49:33 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-07-21 08:50:01 +0000 |
commit | 0696566b1e19c8178e00c0d14f185935e17d9e8b (patch) | |
tree | 8304183e9e1b153cb3e7a2f85277f3aa358ed490 /src/corelib/io/qfsfileengine_win.cpp | |
parent | 1ef8c640f8d2ef57f6779dd2749058a082394bcc (diff) |
Windows: Fix truncation in QFSFileEnginePrivate::nativeWrite()
The number of bytes to write was converted to a 32bit unsigned value,
causing losses. Change the type to qint64 and adapt the code determining
the block size.
Task-number: QTBUG-54870
Change-Id: I294da5bfe97c7e60f67228399e1244a1aba4c89c
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/corelib/io/qfsfileengine_win.cpp')
-rw-r--r-- | src/corelib/io/qfsfileengine_win.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 689251a6c7..391fbcc519 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -423,15 +423,13 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) if (fileHandle == INVALID_HANDLE_VALUE) return -1; - qint64 bytesToWrite = DWORD(len); // <- lossy + qint64 bytesToWrite = len; // Writing on Windows fails with ERROR_NO_SYSTEM_RESOURCES when // the chunks are too large, so we limit the block size to 32MB. - static const DWORD maxBlockSize = 32 * 1024 * 1024; - + const DWORD blockSize = DWORD(qMin(bytesToWrite, qint64(32 * 1024 * 1024))); qint64 totalWritten = 0; do { - DWORD blockSize = qMin<DWORD>(bytesToWrite, maxBlockSize); DWORD bytesWritten; if (!WriteFile(fileHandle, data + totalWritten, blockSize, &bytesWritten, NULL)) { if (totalWritten == 0) { |