From c53e12f25da6330767e7024164fc228169b3df42 Mon Sep 17 00:00:00 2001 From: Lu YaNing Date: Tue, 3 Jan 2023 14:50:53 +0800 Subject: Add Q_ASSERT for _context pointer to avoid null pointer dereference Amends to ae1334d827bd386ae34ed5fca8f00dcef83bc65e Pick-to: 6.5 Change-Id: Ie9ed277b7462268d778e7148ce7e67655b420154 Reviewed-by: Ulf Hermann --- src/qml/compiler/qv4compilerscanfunctions.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 380cf66f47..f667548878 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -416,9 +416,10 @@ bool ScanFunctions::visit(TemplateLiteral *ast) bool ScanFunctions::visit(SuperLiteral *) { + Q_ASSERT(_context); Context *c = _context; bool needContext = false; - while (c && (c->contextType == ContextType::Block || c->isArrowFunction)) { + while (c->contextType == ContextType::Block || c->isArrowFunction) { needContext |= c->isArrowFunction; c = c->parent; } -- cgit v1.2.1