From af335a89bd2f8b41c059c1467bac55fdaf4f2dc0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 30 Jun 2022 17:45:07 +0200 Subject: QmlCompiler: Initialize registers with undefined where necessary If we read the initial state of a register, we need to make sure it actually exists at that point. Uninitialized variables are implicitly undefined in JavaScript. Pick-to: 6.4 Task-number: QTBUG-104687 Change-Id: Ide4fe429b10ec28dcf267e7d34c6316355b16baa Reviewed-by: Fabian Kosmale --- src/qmlcompiler/qqmljsfunctioninitializer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/qmlcompiler/qqmljsfunctioninitializer.cpp') diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp index e04a4ef9ee..56d1d25124 100644 --- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp +++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp @@ -97,6 +97,12 @@ void QQmlJSFunctionInitializer::populateSignature( } } + for (int i = QQmlJSCompilePass::FirstArgument + function->argumentTypes.length(); + i < context->registerCountInFunction; ++i) { + function->registerTypes.append(m_typeResolver->tracked( + m_typeResolver->globalType(m_typeResolver->voidType()))); + } + function->addressableScopes = m_typeResolver->objectsById(); function->code = context->code; function->sourceLocations = context->sourceLocationTable.get(); -- cgit v1.2.3