aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4stackframe.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-07-21 15:02:02 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-07-22 09:08:25 +0200
commitc02b0e529a3266cce2f7d852deca7774402b236e (patch)
tree958f6978bc618a70dfe419f6c2be492307f6d92f /src/qml/jsruntime/qv4stackframe.cpp
parent9e03741e54768f99dac166bd56b0e8cb6d85ca36 (diff)
Qml: When cloning a stack frame, also clone its instruction pointer
Otherwise we get an out of range access when looking for the line number. To be extra safe, we also add another guard against this to the lineNumber() function. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-90466 Change-Id: I4d9cb52ecba2631696537f02a3c1b75c3658ceb8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4stackframe.cpp')
-rw-r--r--src/qml/jsruntime/qv4stackframe.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4stackframe.cpp b/src/qml/jsruntime/qv4stackframe.cpp
index ebbfaa23ea..a02ce0edc5 100644
--- a/src/qml/jsruntime/qv4stackframe.cpp
+++ b/src/qml/jsruntime/qv4stackframe.cpp
@@ -19,7 +19,7 @@ QString CppStackFrame::function() const
int CppStackFrame::lineNumber() const
{
- if (!v4Function)
+ if (!v4Function || instructionPointer <= 0)
return -1;
auto findLine = [](const CompiledData::CodeOffsetToLine &entry, uint offset) {
@@ -27,9 +27,9 @@ int CppStackFrame::lineNumber() const
};
const QV4::CompiledData::Function *cf = v4Function->compiledFunction;
- uint offset = instructionPointer;
+ const uint offset = instructionPointer;
const CompiledData::CodeOffsetToLine *lineNumbers = cf->lineNumberTable();
- uint nLineNumbers = cf->nLineNumbers;
+ const uint nLineNumbers = cf->nLineNumbers;
const CompiledData::CodeOffsetToLine *line = std::lower_bound(lineNumbers, lineNumbers + nLineNumbers, offset, findLine) - 1;
return line->line;
}