From 60176efa7843fda048b2eb5d347fab0dd991e26d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 May 2018 12:55:11 +0200 Subject: Fix crash when incubating objects with non-existent initial properties When incubation is triggered from C++ and reaches the state of setting the initial properties (as supplied to incubateObject), we'd set engine->currentStackFrame to a CppStackFrame that provides access to the correct QML context. As we're not called from the interpreter, the v4Function pointer would be a null pointer. If during the initial property setting an exception is thrown (due to non-existent property access) and a back-trace is created, we'd end up dereferencing v4Function. Change-Id: I7f6b0ba7893bfb4186f55d4c213b4bb602d29aa0 Task-number: QTBUG-68416 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4engine.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/qml/jsruntime/qv4engine.cpp') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 5521633db7..835933c043 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -769,16 +769,19 @@ QQmlContextData *ExecutionEngine::callingQmlContext() const QString CppStackFrame::source() const { - return v4Function->sourceFile(); + return v4Function ? v4Function->sourceFile() : QString(); } QString CppStackFrame::function() const { - return v4Function->name()->toQString(); + return v4Function ? v4Function->name()->toQString() : QString(); } int CppStackFrame::lineNumber() const { + if (!v4Function) + return -1; + auto findLine = [](const CompiledData::CodeOffsetToLine &entry, uint offset) { return entry.codeOffset < offset; }; -- cgit v1.2.3