diff options
author | Liang Qi <liang.qi@qt.io> | 2019-08-12 13:23:11 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-08-12 13:23:11 +0200 |
commit | 44c393f9b61797a240bfcbff1364ecdf7af41787 (patch) | |
tree | 94cca729399f5df23cf904f7bd866397d84aac7c /src/corelib/tools | |
parent | ffc2d5722317fcab86865b11491d7bf7fef3e16d (diff) | |
parent | e66f247ccf345f1d303a92e53c21bb53d96c5af2 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
config.tests/arch/write_info.pri
Repair architecture config test for the WASM_OBJECT_FILES=1 build mode
configure.pri
tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
Done-With: Jörg Bornemann <joerg.bornemann@qt.io>
Change-Id: I9e12088356eb5bc65b53211cd7a8e330cccd1bb4
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qbitarray.cpp | 12 | ||||
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 8 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index 4952090620..f0b81cce66 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -132,12 +132,12 @@ QT_BEGIN_NAMESPACE * We overallocate the byte array by 1 byte. The first user bit is at * d.data()[1]. On the extra first byte, we store the difference between the * number of bits in the byte array (including this byte) and the number of - * bits in the bit array. Therefore, it's always a number between 8 and 15. + * bits in the bit array. Therefore, for a non-empty QBitArray, it's always a + * number between 8 and 15. For the empty one, d is the an empty QByteArray and + * *d.constData() is the QByteArray's terminating NUL (0) byte. * * This allows for fast calculation of the bit array size: * inline int size() const { return (d.size() << 3) - *d.constData(); } - * - * Note: for an array of zero size, *d.constData() is the QByteArray implicit NUL. */ /*! @@ -326,6 +326,8 @@ void QBitArray::fill(bool value, int begin, int end) QBitArray QBitArray::fromBits(const char *data, qsizetype size) { QBitArray result; + if (size == 0) + return result; qsizetype nbytes = (size + 7) / 8; result.d = QByteArray(nbytes + 1, Qt::Uninitialized); @@ -334,7 +336,7 @@ QBitArray QBitArray::fromBits(const char *data, qsizetype size) // clear any unused bits from the last byte if (size & 7) - bits[nbytes] &= 0xffU >> (size & 7); + bits[nbytes] &= 0xffU >> (8 - (size & 7)); *bits = result.d.size() * 8 - size; return result; diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 3c79bb797d..51f48503fb 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -387,19 +387,19 @@ void QCryptographicHash::addData(const char *data, int length) break; case RealSha3_224: case Keccak_224: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; case RealSha3_256: case Keccak_256: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; case RealSha3_384: case Keccak_384: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; case RealSha3_512: case Keccak_512: - sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), length*8); + sha3Update(&d->sha3Context, reinterpret_cast<const BitSequence *>(data), quint64(length) * 8); break; #endif } |