QCryptographicHash: make narrowing in addData(QIODevice*) explicit

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.

Pick-to: 6.5
Change-Id: I5f95292ca6e05f0f402e7258e590593eff361255
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2023-02-21 11:13:37 +01:00
parent d32d2137b7
commit 303caa40da

View File

@ -696,10 +696,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();
}