summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2016-04-18 23:27:12 +0200
committerStephen Kelly <steveire@gmail.com>2016-04-21 21:13:08 +0000
commit9def501433e80e1a45c0d7888b9ceba4e32ca1fa (patch)
tree28ed0a024ce1ad9077b3c2e3e5a0f93cd205c26c /src/corelib/tools
parentbbd1228b17ee3f3a5483f88b0a581d6a60c41cad (diff)
QString: Avoid searching for a needle which is longer than the hay
Avoid incurring the cost of converting the latin1 data in that case. Several existing QString unit tests excercise the new code path. Task-number: QTBUG-52617 Change-Id: I27256d9e7db34f09543e244a79d754ff7932f0d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qstring.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 10d3441d2c..983d1213d9 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -10005,6 +10005,9 @@ static inline int qt_find_latin1_string(const QChar *haystack, int size,
QLatin1String needle,
int from, Qt::CaseSensitivity cs)
{
+ if (size < needle.size())
+ return -1;
+
const char *latin1 = needle.latin1();
int len = needle.size();
QVarLengthArray<ushort> s(len);