diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 32642b83e39..4d862054884 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -1209,13 +1209,11 @@ QByteArray &QByteArray::operator=(const QByteArray & other) noexcept QByteArray &QByteArray::operator=(const char *str) { if (!str || !*str) { - QPair pair; if (!str) { - pair = qMakePair(Data::sharedNull(), Data::sharedNullData()); + d.clear(); } else { - pair = Data::allocate(0); + d = QByteArrayData(Data::allocate(0), 0); } - d = QByteArrayData(pair.first, pair.second, 0); } else { const int len = int(strlen(str)); const uint fullLen = uint(len) + 1;