aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-05-04 13:56:44 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-05-04 12:08:08 +0000
commit98fc9aa2d41d71e0c091e52d3a7417803dd47de7 (patch)
tree696ca22c48c94b1740c7eb49a2e87c10fe274701 /src/qml/compiler/qv4compileddata.cpp
parent2044d0a03bafa4597863eb2bf3ecb8fa6731ed57 (diff)
Fix crash when loading ahead-of-time generated cache files
When an ahead-of-time generated cache file contains signal handler expressions, then we need change the QV4::Function and signal parameter tables in the compilation unit to include the signal parameters (so that an onClicked handler has access to the hidden "mouse" parameter). If however it turns out that the signal has no parameters, then the formal parameter list is empty. Before commit da5fffbd34d8be68f8ee4c649881dbb673c9c0a5 the code could deal with an empty linked list, but after the change params were dereferenced unconditionally, leading particularly on ARM to crashes because we called params->formals() with params == nullptr. Amends commit 3f82c8131fed248c24ed8c8be7449b4732afcd0b. Change-Id: I33844e28a6224550d6196503e207c4c99a9704b1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compileddata.cpp')
-rw-r--r--src/qml/compiler/qv4compileddata.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 0a4ba72cf0..4c0bbd9dfa 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -508,9 +508,11 @@ Unit *CompilationUnit::createUnitData(QmlIR::Document *irDocument)
QQmlJS::AST::FormalParameterList *parameters = QQmlJS::AST::cast<QQmlJS::AST::FunctionDeclaration*>(foe->node)->formals;
changedSignalParameters << parameters;
- const QStringList formals = parameters->formals();
- for (const QString &arg : formals)
- stringTable.registerString(arg);
+ if (parameters) {
+ const QStringList formals = parameters->formals();
+ for (const QString &arg : formals)
+ stringTable.registerString(arg);
+ }
}
}
@@ -533,11 +535,13 @@ Unit *CompilationUnit::createUnitData(QmlIR::Document *irDocument)
function->formalsOffset = signalParameterNameTableOffset - jsUnit->functionOffsetTable()[functionIndex];
- const QStringList formals = changedSignalParameters.at(i)->formals();
- for (const QString &arg : formals)
- signalParameterNameTable.append(stringTable.getStringId(arg));
+ if (QQmlJS::AST::FormalParameterList *parameters = changedSignalParameters.at(i)) {
+ const QStringList formals = parameters->formals();
+ for (const QString &arg : formals)
+ signalParameterNameTable.append(stringTable.getStringId(arg));
- function->nFormals = formals.size();
+ function->nFormals = formals.size();
+ }
function->length = function->nFormals;
signalParameterNameTableOffset += function->nFormals * sizeof(quint32);