OSDN Git Service

pre-allocate result based on the converted domain in QString QUrl::fromAce()
authorIvailo Monev <xakepa10@gmail.com>
Sun, 24 Jan 2021 13:24:17 +0000 (15:24 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 24 Jan 2021 13:24:17 +0000 (15:24 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/io/qurl.cpp

index 9c1c4c5..0e6fcb4 100644 (file)
@@ -3497,7 +3497,7 @@ QString QUrl::fromAce(const QByteArray &domain)
     const QString utf8 = QString::fromUtf8(domain);
     UErrorCode error = U_ZERO_ERROR;
     UIDNAInfo info = UIDNA_INFO_INITIALIZER;
-    QString result(domain.size() * 4, Qt::Uninitialized);
+    QString result(utf8.size() * 4, Qt::Uninitialized);
     const int idnaresult = uidna_nameToUnicode(globalidna,
         reinterpret_cast<const UChar*>(utf8.unicode()), utf8.size(),
         reinterpret_cast<UChar*>(result.data()), result.size(),