diff options
Diffstat (limited to 'src/corelib/tools/qbitarray.cpp')
| -rw-r--r-- | src/corelib/tools/qbitarray.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index e4276d383d1..d5643df0250 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -531,12 +531,17 @@ static QBitArray sizedForOverwrite(const QBitArray &a1, const QBitArray &a2) QByteArrayData bytes(n, n); // initialize the count of bits in the last byte (see construction note) - if (n1 > n2) + // and the QByteArray null termination (some of our algorithms read it) + if (n1 > n2) { *bytes.ptr = *d1.ptr; - else if (n2 > n1) + bytes.ptr[n1] = 0; + } else if (n2 > n1) { *bytes.ptr = *d2.ptr; - else if (n1) // n1 == n2 + bytes.ptr[n2] = 0; + } else if (n1) { // n1 == n2 *bytes.ptr = qMin(*d1.ptr, *d2.ptr); + bytes.ptr[n1] = 0; + } result.data_ptr() = std::move(bytes); return result; |
