diff options
author | Dominik Holland <dominik.holland@qt.io> | 2022-08-25 15:16:50 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-27 16:40:19 +0000 |
commit | 91cf92f2e5e3ca5ef425848ed2106d11e59854d0 (patch) | |
tree | ad0c80e5f2ee902496bf6ad7062938d1f3cc062a | |
parent | 4eeffd8725004d9628cfa6e581519d375942c0cf (diff) |
repc: Fix warning in generated code
This ammends acd888220b9d600fe057249d43bd3934ae0cbad5 and adds
the same check to three other methods as well.
Fixes: QTBUG-97790
Change-Id: Iecad6dbd1b99842a2c8802af2d973f9eb986d81e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
(cherry picked from commit 288859e96ccc1bc733ebd7924d3ce36f4f01d24f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tools/repc/repcodegenerator.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/repc/repcodegenerator.cpp b/tools/repc/repcodegenerator.cpp index dcf3730..693946e 100644 --- a/tools/repc/repcodegenerator.cpp +++ b/tools/repc/repcodegenerator.cpp @@ -1243,7 +1243,9 @@ void RepCodeGenerator::generateSourceAPI(const ASTClass &astClass) m_stream << QStringLiteral(" }") << Qt::endl; m_stream << QStringLiteral(" int sourceMethodIndex(int index) const override") << Qt::endl; m_stream << QStringLiteral(" {") << Qt::endl; - m_stream << QStringLiteral(" if (index < 0 || index >= m_methods[0])") << Qt::endl; + m_stream << QStringLiteral(" if (index < 0 || index >= m_methods[0]" + " || index + 1 >= int(std::size(m_methods)))") + << Qt::endl; m_stream << QStringLiteral(" return -1;") << Qt::endl; m_stream << QStringLiteral(" return m_methods[index+1];") << Qt::endl; m_stream << QStringLiteral(" }") << Qt::endl; @@ -1388,7 +1390,9 @@ void RepCodeGenerator::generateSourceAPI(const ASTClass &astClass) QStringLiteral(" QByteArrayList signalParameterNames(int index) const override") << Qt::endl; m_stream << QStringLiteral(" {") << Qt::endl; - m_stream << QStringLiteral(" if (index < 0 || index >= m_signals[0])") << Qt::endl; + m_stream << QStringLiteral(" if (index < 0 || index >= m_signals[0]" + " || index + 1 >= int(std::size(m_signals)))") + << Qt::endl; m_stream << QStringLiteral(" return QByteArrayList();") << Qt::endl; m_stream << QStringLiteral(" return ObjectType::staticMetaObject.method(m_signals[" "index + 1]).parameterNames();") << Qt::endl; @@ -1458,7 +1462,9 @@ void RepCodeGenerator::generateSourceAPI(const ASTClass &astClass) QStringLiteral(" QByteArrayList methodParameterNames(int index) const override") << Qt::endl; m_stream << QStringLiteral(" {") << Qt::endl; - m_stream << QStringLiteral(" if (index < 0 || index >= m_methods[0])") << Qt::endl; + m_stream << QStringLiteral(" if (index < 0 || index >= m_methods[0]" + " || index + 1 >= int(std::size(m_methods)))") + << Qt::endl; m_stream << QStringLiteral(" return QByteArrayList();") << Qt::endl; m_stream << QStringLiteral(" return ObjectType::staticMetaObject.method(m_methods[" "index + 1]).parameterNames();") << Qt::endl; |