Return empty string instead of 1 as adler32 checksum for empty files

This commit is contained in:
Hannah von Reth 2020-08-14 16:15:30 +02:00 committed by Kevin Ottens
parent 23f7c51f70
commit 1aa1ea7bea
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2

View file

@ -114,6 +114,10 @@ QByteArray calcSha1(QIODevice *device)
#ifdef ZLIB_FOUND #ifdef ZLIB_FOUND
QByteArray calcAdler32(QIODevice *device) QByteArray calcAdler32(QIODevice *device)
{ {
if (device->size() == 0)
{
return QByteArray();
}
QByteArray buf(BUFSIZE, Qt::Uninitialized); QByteArray buf(BUFSIZE, Qt::Uninitialized);
unsigned int adler = adler32(0L, Z_NULL, 0); unsigned int adler = adler32(0L, Z_NULL, 0);