From c42a22e15e8a312558efc5c4d1c121cd028c04d4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 21 Feb 2023 11:13:37 +0100 Subject: [PATCH] QCryptographicHash: make narrowing in addData(QIODevice*) explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QIODevice::read(ptr, n) returns qint64, not int. The returned values are, however, confined to the interval [-1,1024], so no harm done. Make the narrowing explicit, though. Change-Id: I5f95292ca6e05f0f402e7258e590593eff361255 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira (cherry picked from commit 303caa40da6cee296ffcee3ae13b88d788a2e225) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/tools/qcryptographichash.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 65c6bfdad1a..3b1208be7ac 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -697,10 +697,10 @@ bool QCryptographicHash::addData(QIODevice *device) return false; char buffer[1024]; - int length; + qint64 length; while ((length = device->read(buffer, sizeof(buffer))) > 0) - d->addData({buffer, length}); + d->addData({buffer, qsizetype(length)}); // length always <= 1024 return device->atEnd(); }