summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-11-29 17:22:04 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-11-30 00:04:38 +0100
commitbe84b033dca2bb347c4c6c4d7e487d2cb0a2502b (patch)
treeb2362aef7dc3341a8be80dfb13dde0308ad3f562
parent4c930e9d13738ac0faaaed3aa5b1c34509b04019 (diff)
QRegularExpression: don't detach() a pattern QStringLiteral
... just to pass it to pcre2_compile_16(). The QString::utf16() function guarantees a NUL-terminated result, so it detach()es from QStringLiteral (Qt 6) and/or QString::fromRawData() (Qt 5 + 6). This user doesn't require the NUL-termination, though, since pcre2_compile_16() takes an explicit length, so the detach() is completely unneccesary, yet common, since regex pattern strings are often QStringLiteral()s. Task-number: QTBUG-98763 Change-Id: I1d08ae1a1ec4281ff44a68c5ba5c56584b71d24e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-rw-r--r--src/corelib/text/qregularexpression.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp
index 4fe86e9d6a..1db27fc4e4 100644
--- a/src/corelib/text/qregularexpression.cpp
+++ b/src/corelib/text/qregularexpression.cpp
@@ -910,7 +910,7 @@ void QRegularExpressionPrivate::compilePattern()
options |= PCRE2_UTF;
PCRE2_SIZE patternErrorOffset;
- compiledPattern = pcre2_compile_16(reinterpret_cast<PCRE2_SPTR16>(pattern.utf16()),
+ compiledPattern = pcre2_compile_16(reinterpret_cast<PCRE2_SPTR16>(pattern.constData()),
pattern.length(),
options,
&errorCode,