warn if QCryptographicHash::hash() is called with empty data

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-29 15:54:45 +02:00
parent ac0689a666
commit 35205fd485

View file

@ -198,6 +198,10 @@ QByteArray QCryptographicHash::result() const
*/
QByteArray QCryptographicHash::hash(const QByteArray &data)
{
if (Q_UNLIKELY(data.isEmpty())) {
qWarning("QCryptographicHash::hash called without any data");
return QByteArray();
}
QCryptographicHashPrivate kathash;
kathash.update(data.constData(), data.length());
return kathash.result();