From 96d057e6a5138918c9f8b92ce3320042fa6417fc Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 7 Dec 2016 11:17:30 +0100 Subject: V4 Interpreter: reset the exception handler for every catch block If an exception handler consists of multiple basic-blocks, and is then followed by a finally block (for example: a catch block with a throw followed by a return, and then a subsequent finally block), then the finally block can be reached before the exception handler is reset by skipping the second block of the catch handler with a throw. As the finally block will then rethrow, and the old exception handler is still there, it will end in an endless loop. The fix is to reset the exception handler for every catch block. The problem occurred in ch12/12.14/S12.14_A13_T3 Change-Id: I968b62c6c2af30af32e2717a9ce85f852523dbe8 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4isel_moth.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp index ca6319ef3c..f2bd57ad8f 100644 --- a/src/qml/compiler/qv4isel_moth.cpp +++ b/src/qml/compiler/qv4isel_moth.cpp @@ -242,6 +242,11 @@ void InstructionSelection::run(int functionIndex) addInstruction(set); } exceptionHandler = _block->catchBlock; + } else if (_block->catchBlock == nullptr && _block->index() != 0 && _block->in.isEmpty()) { + exceptionHandler = nullptr; + Instruction::SetExceptionHandler set; + set.offset = 0; + addInstruction(set); } for (IR::Stmt *s : _block->statements()) { -- cgit v1.2.3