From b101be9be64b6cc82dc357da0faeffbaab771b8f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 23 Sep 2022 13:30:05 +0200 Subject: [PATCH] QV4::Function: Reduce nFormals to 16 bits This saves some space due to better alignment. We cannot have more bits in the compilation unit anyway. If we were to get a signal with more formal parameters than that, we just produce an error now. Change-Id: I02c329590b2d18337eca7441529b5cd4e19349f7 Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4function_p.h | 2 +- src/qml/qml/qqmlpropertycache.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 072c0fb9cc..67d31b6c6c 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -78,8 +78,8 @@ public: // first nArguments names in internalClass are the actual arguments Heap::InternalClass *internalClass; - uint nFormals; int interpreterCallCount = 0; + quint16 nFormals; bool isEval = false; bool detectedInjectedParameters = false; diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index e91148f66c..c7eed14593 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -743,13 +743,17 @@ QString QQmlPropertyCache::signalParameterStringForJS(QV4::ExecutionEngine *engi const QSet &illegalNames = engine->illegalNames(); QString parameters; - for (int i = 0; i < parameterNameList.count(); ++i) { + const qsizetype count = parameterNameList.count(); + if (count > std::numeric_limits::max()) + *errorString = QCoreApplication::translate("QQmlRewrite", "Signal has an excessive number of parameters: %1").arg(count); + + for (qsizetype i = 0; i < count; ++i) { if (i > 0) parameters += QLatin1Char(','); const QByteArray ¶m = parameterNameList.at(i); - if (param.isEmpty()) + if (param.isEmpty()) { unnamedParameter = true; - else if (unnamedParameter) { + } else if (unnamedParameter) { if (errorString) *errorString = QCoreApplication::translate("QQmlRewrite", "Signal uses unnamed parameter followed by named parameter."); return QString();