summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2020-11-19 14:26:18 +0100
committerAndreas Buhr <andreas.buhr@qt.io>2020-11-19 20:28:27 +0100
commitebaae45ea17efc230209ed90d94596647cf6cb48 (patch)
tree649ef0a6282b274ff8776d091106829bebb6b1ce /src
parentd3ba1b321b23eb807e3af9bfaa3a0db6d7a153c7 (diff)
Fix logic error in QString::replace(ch, after, cs)
Coverage analysis showed that an if-branch marked "Q_LIKELY" was never taken. It turns out the code was incorrect, but behaved correctly. This patch fixes the logic and adds a unit test. Pick-to: 5.15 Change-Id: I9b4ba76392b52f07b8e21188496e23f98dba95a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/text/qstring.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 091f44736e..dd00456fb2 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -3382,7 +3382,7 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs
replace_helper(indices, pos, 1, after.constData(), after.size());
- if (Q_LIKELY(index == -1)) // Nothing left to replace
+ if (Q_LIKELY(index == size())) // Nothing left to replace
break;
// The call to replace_helper just moved what index points at:
index += pos*(after.size() - 1);