From 3f82c8131fed248c24ed8c8be7449b4732afcd0b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 30 Apr 2018 12:34:54 +0200 Subject: Fix crashes when parsing functions with no parameters Commit da5fffbd34d8be68f8ee4c649881dbb673c9c0a5 introduced deferencing of the formals parameter list that can be a null pointer if the declared function has no parameters. Change-Id: Id7dce0f78b16266e672f0ae430ee4f979de5734d Reviewed-by: Erik Verbruggen Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4compilerscanfunctions.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index c6e792fc45..3bbef3a96a 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -420,7 +420,7 @@ bool ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParamete outerContext->usesArgumentsObject = Context::ArgumentsObjectNotUsed; } - if (formals->containsName(QStringLiteral("arguments"))) + if (formals && formals->containsName(QStringLiteral("arguments"))) _context->usesArgumentsObject = Context::ArgumentsObjectNotUsed; if (expr) { if (expr->isArrowFunction) @@ -430,18 +430,18 @@ bool ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParamete } - if (!name.isEmpty() && !formals->containsName(name)) + if (!name.isEmpty() && (!formals || !formals->containsName(name))) _context->addLocalVar(name, Context::ThisFunctionName, VariableScope::Var); _context->formals = formals; if (body && !_context->isStrict) checkDirectivePrologue(body); - bool isSimpleParameterList = formals->isSimpleParameterList(); + bool isSimpleParameterList = formals && formals->isSimpleParameterList(); - _context->arguments = formals->formals(); + _context->arguments = formals ? formals->formals() : QStringList(); - const QStringList boundNames = formals->boundNames(); + const QStringList boundNames = formals ? formals->boundNames() : QStringList(); for (int i = 0; i < boundNames.size(); ++i) { const QString &arg = boundNames.at(i); if (_context->isStrict || !isSimpleParameterList) { -- cgit v1.2.3