From f6735dba9518ffc896541f212fade350e18c91de Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 15 Aug 2023 10:30:44 +0200 Subject: QmlCompiler: Fix console logging Store a copy of the UTF-8 data for file and function so that we don't run into heap-use-after-free. Set the instruction pointer before calling the log function so that we get a correct line number. Pick-to: 6.6 6.5 Fixes: QTBUG-114655 Change-Id: I38249fe52719ddad620033716ff22b2087ab8382 Reviewed-by: Fabian Kosmale --- src/qml/qml/qqml.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/qml/qml/qqml.cpp') diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index f951fb6a14..1e051fd37a 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -1472,8 +1472,10 @@ void AOTCompiledContext::writeToConsole( const QV4::CppStackFrame *frame = engine->handle()->currentStackFrame; Q_ASSERT(frame); - QMessageLogger logger(qUtf8Printable(frame->source()), frame->lineNumber(), - qUtf8Printable(frame->function()), loggingCategory->categoryName()); + const QByteArray source(frame->source().toUtf8()); + const QByteArray function(frame->function().toUtf8()); + QMessageLogger logger(source.constData(), frame->lineNumber(), + function.constData(), loggingCategory->categoryName()); switch (type) { case QtDebugMsg: -- cgit v1.2.3