summaryrefslogtreecommitdiffstats
path: root/src/corelib/compat
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-21 15:02:08 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-01-23 01:06:57 +0000
commit3d3558dc8f0a1885f416b4650037364f4ef11bd4 (patch)
tree33c0a28a52ec17c86057ba4632e68f92bb2266a0 /src/corelib/compat
parent3ec587666f89c996cc0a403775c352954d8b804f (diff)
QStaticByteArrayMatcher: fix searching in 2+GiB haystacks
Add a test (same techniques as for the 4+GiB check in tst_qcryptographichash). Takes ~1s to build the 4GiB test data here, and skips when RAM is too low: $ qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork [...] QDEBUG : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() created dataset in 891 ms [...] $ (ulimit -v 2000000; qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork) ********* Start testing of tst_QByteArrayMatcher ********* [...] SKIP : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() Could not allocate 4GiB plus a couple hundred bytes of RAM. Loc: [/home/marc/Qt/qt5/qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp(242)] [...] Found during 6.3 API review. [ChangeLog][QtCore][QStaticByteArrayMatcher] Fixed searching in strings with size > 2GiB (on 64-bit platforms). Fixes: QTBUG-100118 Pick-to: 6.3 Change-Id: I1df420965673b5555fef2b75e785954cc50b654f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/compat')
-rw-r--r--src/corelib/compat/removed_api.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp
index d27656bf7a..4cc0bffe20 100644
--- a/src/corelib/compat/removed_api.cpp
+++ b/src/corelib/compat/removed_api.cpp
@@ -62,6 +62,19 @@ int QMetaType::id() const
#if QT_REMOVED_SINCE(6, 3)
+#include "qbytearraymatcher.h"
+
+# if QT_POINTER_SIZE != 4
+
+int QStaticByteArrayMatcherBase::indexOfIn(const char *h, uint hl, const char *n, int nl, int from) const noexcept
+{
+ qsizetype r = indexOfIn(h, size_t(hl), n, qsizetype(nl), qsizetype(from));
+ Q_ASSERT(r == int(r));
+ return r;
+}
+
+# endif // QT_POINTER_SIZE != 4
+
#include "tools/qcryptographichash.h"
void QCryptographicHash::addData(const QByteArray &data)