qt6-bb10/tests/auto/corelib
Marc Mutz 15422d191f qputenv: defend against non-NUL-terminated QByteArray values
The old code assumed that a QByteArray's data() is always
NUL-terminated. Due to the conflation of owners and non-owners in
QByteArray (but also in case we ever get efficient substringing), this
is not always the case, e.g. QByteArray::fromRawData() does not ensure
NUL-termination.

From QString::utf16(), we learn that the condition to check for is
QArrayData::isMutable(). After working around the fact that
QByteArray::data_ptr() doesn't exist for const QBAs and that empty
QBAs always refer to QByteArray::empty_, which is !isMutable(), we can
detect this situation and re-allocate without introducing new API.

This is the fix for Qt ≤ 6.4. For Qt 6.5, we'll port the function to
QByteArrayView.

Pick-to: 6.4 6.3 6.2 5.15
Fixes: QTBUG-105302
Change-Id: I3416535ab09d601e0e87b2767f2c024ba1217e64
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-08-05 19:42:05 +02:00
..
animation Add license headers to cmake files 2022-08-03 17:14:55 +02:00
global qputenv: defend against non-NUL-terminated QByteArray values 2022-08-05 19:42:05 +02:00
io QtBase: Windows: Replace some deprecated API usages 2022-08-03 23:24:21 +08:00
itemmodels Add license headers to cmake files 2022-08-03 17:14:55 +02:00
kernel Add license headers to cmake files 2022-08-03 17:14:55 +02:00
mimetypes Add license headers to cmake files 2022-08-03 17:14:55 +02:00
platform Add license headers to cmake files 2022-08-03 17:14:55 +02:00
plugin Add license headers to cmake files 2022-08-03 17:14:55 +02:00
serialization Add license headers to cmake files 2022-08-03 17:14:55 +02:00
text Add Latin 1 case-insensitive Boyer-Moore searcher 2022-08-04 23:12:39 +02:00
thread Add license headers to cmake files 2022-08-03 17:14:55 +02:00
time Rearrange the skipping of a test to give a better message 2022-08-03 18:38:53 +02:00
tools Add license headers to cmake files 2022-08-03 17:14:55 +02:00
CMakeLists.txt Add license headers to cmake files 2022-08-03 17:14:55 +02:00