diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-01-21 15:02:08 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-01-23 01:06:57 +0000 |
commit | 3d3558dc8f0a1885f416b4650037364f4ef11bd4 (patch) | |
tree | 33c0a28a52ec17c86057ba4632e68f92bb2266a0 /src/corelib/text/qbytearraymatcher.cpp | |
parent | 3ec587666f89c996cc0a403775c352954d8b804f (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/text/qbytearraymatcher.cpp')
-rw-r--r-- | src/corelib/text/qbytearraymatcher.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/text/qbytearraymatcher.cpp b/src/corelib/text/qbytearraymatcher.cpp index 7ade5bc5b7..ee4d8d265b 100644 --- a/src/corelib/text/qbytearraymatcher.cpp +++ b/src/corelib/text/qbytearraymatcher.cpp @@ -395,7 +395,7 @@ qsizetype qFindByteArray( */ /*! - \fn template <uint N> int QStaticByteArrayMatcher<N>::indexIn(const char *haystack, int hlen, int from = 0) const + \fn template <size_t N> qsizetype QStaticByteArrayMatcher<N>::indexIn(const char *haystack, qsizetype hlen, qsizetype from = 0) const Searches the char string \a haystack, which has length \a hlen, from byte position \a from (default 0, i.e. from the first byte), for @@ -405,7 +405,7 @@ qsizetype qFindByteArray( */ /*! - \fn template <uint N> int QStaticByteArrayMatcher<N>::indexIn(const QByteArray &haystack, int from = 0) const + \fn template <size_t N> qsizetype QStaticByteArrayMatcher<N>::indexIn(const QByteArray &haystack, qsizetype from = 0) const Searches the char string \a haystack, from byte position \a from (default 0, i.e. from the first byte), for the byte array pattern() @@ -415,7 +415,7 @@ qsizetype qFindByteArray( */ /*! - \fn template <uint N> QByteArray QStaticByteArrayMatcher<N>::pattern() const + \fn template <size_t N> QByteArray QStaticByteArrayMatcher<N>::pattern() const Returns the byte array pattern that this byte array matcher will search for. @@ -426,7 +426,7 @@ qsizetype qFindByteArray( /*! \internal */ -int QStaticByteArrayMatcherBase::indexOfIn(const char *needle, uint nlen, const char *haystack, int hlen, int from) const noexcept +qsizetype QStaticByteArrayMatcherBase::indexOfIn(const char *needle, size_t nlen, const char *haystack, qsizetype hlen, qsizetype from) const noexcept { if (from < 0) from = 0; @@ -435,12 +435,12 @@ int QStaticByteArrayMatcherBase::indexOfIn(const char *needle, uint nlen, const } /*! - \fn template <uint N> QStaticByteArrayMatcher<N>::QStaticByteArrayMatcher(const char (&pattern)[N]) + \fn template <size_t N> QStaticByteArrayMatcher<N>::QStaticByteArrayMatcher(const char (&pattern)[N]) \internal */ /*! - \fn template <uint N> QStaticByteArrayMatcher qMakeStaticByteArrayMatcher(const char (&pattern)[N]) + \fn template <size_t N> QStaticByteArrayMatcher qMakeStaticByteArrayMatcher(const char (&pattern)[N]) \since 5.9 \relates QStaticByteArrayMatcher |