diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-07-09 18:16:13 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-07-09 18:38:33 +0200 |
commit | 577558daf5a2709722cb7980f194cbbc6a8287a3 (patch) | |
tree | c46e04ac0c6439ce9eb533146cc7feb37a949a0d /src/corelib/text/qbytearray.cpp | |
parent | c023b025ee7f3e221b1ad947722ec4d4fa5f5e5e (diff) |
Fix QByteArray::count implementation for longer data
The issue has been introduced when refactoring QByteArray::count
implementation (see 631127126cc14e7c01cc611532b3256b58785670).
Because the last argument of QByteArrayMatcher::indexIn() method
has a defult value, it has been compiling without issues, but was being
called with incorrect size parameter. Fixed it to pass the length of the
input data correctly.
Change-Id: Ic9c2f33733131ec17276aa889f2d7ea40ec79b01
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index c498aa30a6..cbcc4e48f7 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -2523,8 +2523,8 @@ qsizetype QtPrivate::count(QByteArrayView haystack, QByteArrayView needle) noexc qsizetype num = 0; qsizetype i = -1; if (haystack.size() > 500 && needle.size() > 5) { - QByteArrayMatcher matcher(needle.data()); - while ((i = matcher.indexIn(haystack.data(), i + 1)) != -1) + QByteArrayMatcher matcher(needle.data(), needle.size()); + while ((i = matcher.indexIn(haystack.data(), haystack.size(), i + 1)) != -1) ++num; } else { while ((i = haystack.indexOf(needle, i + 1)) != -1) |