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>
This commit is contained in:
parent
4c930e9d13
commit
be84b033dc
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user