From 796dd2ab8c7b0e85f2469df9b79f65ca62719c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20De=20Canni=C3=A8re?= Date: Wed, 3 Jan 2024 17:34:59 +0100 Subject: qv4codegen: Do not call functions on null objects inside optional chains Amends: 86c48761dc7ba5bcac7dc6740e94efbfb8678403 Fixes: QTBUG-120504 Pick-to: 6.7 Change-Id: Id77236a07d7c1a16e2f60238909eff245c5c354a Reviewed-by: Ulf Hermann --- src/qml/compiler/qv4codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml/compiler/qv4codegen.cpp') diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 12639cba37..580406db86 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2001,7 +2001,7 @@ bool Codegen::visit(CallExpression *ast) int thisObject = bytecodeGenerator->newRegister(); int functionObject = bytecodeGenerator->newRegister(); - if (ast->isOptional) { + if (ast->isOptional || m_optionalChainsStates.top().actuallyHasOptionals) { base.loadInAccumulator(); bytecodeGenerator->addInstruction(Instruction::CmpEqNull()); auto jumpToUndefined = bytecodeGenerator->jumpTrue(); -- cgit v1.2.3