Otherwise we would traverse beyond bounds. We calculate the delta in sizes between the haystack and the needle and if this delta is smaller than the starting position (the `from` argument) then we start from there. The default value for `from` is size(). With the needle being longer than the haystack, the delta is negative and we set our starting position to be the delta, i.e. we start before the start of the haystack. [ChangeLog][QtCore][QByteArray/QByteArrayView] Fixed a bug in lastIndexOf() that could lead to out-of-bounds access when the needle is longer than the haystack. Pick-to: 6.8 6.5 6.2 5.15 Change-Id: Id5cd772f00b0c3c50fbf61b4e888bba5587391ee Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d25e5e2cb78a2e2f2a1791fed250421ce9eefc46) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
…
…
Description
Languages
C++
84.3%
HTML
4.9%
C
3.9%
CMake
3.6%
Objective-C++
2%
Other
0.8%