Avoid -Wstringop-overread by using a view with encoded length

For some reason the suppression stopped working for me, but using the
viewAt function is better in general as it doesn't depend on null
termination.

Amends da84941375 (viewAt() was added by
2c2c6de85a for 6.3, so we can use it in
all affected branches).

Pick-to: 6.7 6.5
Change-Id: Ic71bd559929a2cd0cdea4ed1cc1edcfc583865ff
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit cec64aaf2a8e110421d61478b9ad0cb177ee0d1c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
bb10
Allan Sandfeld Jensen 2024-10-02 11:36:55 +02:00 committed by Qt Cherry-pick Bot
parent 348d56cca4
commit 68c22bd7d3
1 changed files with 1 additions and 1 deletions

View File

@ -35,7 +35,7 @@ static constexpr auto magicRuleTypes = qOffsetStringArray(
QMimeMagicRule::Type QMimeMagicRule::type(const QByteArray &theTypeName)
{
for (int i = String; i <= Byte; ++i) {
if (theTypeName == magicRuleTypes.at(i))
if (theTypeName == magicRuleTypes.viewAt(i))
return Type(i);
}
return Invalid;