summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJani Heikkinen <jani.heikkinen@qt.io>2021-08-17 07:51:25 +0300
committerJani Heikkinen <jani.heikkinen@qt.io>2021-08-25 07:24:39 +0300
commit8320a92141b736683bb3372f754375cb52836f5d (patch)
tree78e7db129fa7d29e1db844b30a5f8e4d4d56dbc1 /src
parent31ebf45781bdda505adafc76de6117d20069d084 (diff)
Revert "QString::lastIndexOf: fix off-by-one for zero length matches"
This reverts commit be83ff65c424cff1036e7da19d6175826d9f7ed9. The revert is needed as commit caused a regression in QString::lastIndexOf and the regression is more critical than the original issue fixed by the reverted commit. Fixes: QTBUG-94215 Pick-to: 6.1 Change-Id: I785c39d4e0e73f38d5447942357eff0eb19e3f96 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/text/qstring.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index e56de8fd51..a915a7e3bb 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -4366,13 +4366,13 @@ qsizetype QString::lastIndexOf(const QRegularExpression &re, qsizetype from, QRe
return -1;
}
- qsizetype endpos = (from < 0) ? (size() + from + 1) : (from);
+ qsizetype endpos = (from < 0) ? (size() + from + 1) : (from + 1);
QRegularExpressionMatchIterator iterator = re.globalMatch(*this);
qsizetype lastIndex = -1;
while (iterator.hasNext()) {
QRegularExpressionMatch match = iterator.next();
qsizetype start = match.capturedStart();
- if (start <= endpos) {
+ if (start < endpos) {
lastIndex = start;
if (rmatch)
*rmatch = std::move(match);