From 62a581fbb83888e47e1b571bc127c456b6a9ab2b Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Wed, 22 Feb 2017 14:38:52 +0100 Subject: [PATCH] Fix typo in vm_decode_branch_offset. (#1611) Fixes #1597. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/vm/vm-stack.c | 6 ++-- .../fail/1/regression-test-issue-1597.js | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tests/jerry/fail/1/regression-test-issue-1597.js diff --git a/jerry-core/vm/vm-stack.c b/jerry-core/vm/vm-stack.c index da13a3c53..1f25be084 100644 --- a/jerry-core/vm/vm-stack.c +++ b/jerry-core/vm/vm-stack.c @@ -115,13 +115,13 @@ vm_decode_branch_offset (uint8_t *branch_offset_p, /**< start offset of byte cod case 3: { branch_offset <<= 8; - branch_offset |= *(branch_offset_p++); + branch_offset |= *(++branch_offset_p); /* FALLTHRU */ } case 2: { branch_offset <<= 8; - branch_offset |= *(branch_offset_p++); + branch_offset |= *(++branch_offset_p); break; } } @@ -174,7 +174,7 @@ vm_stack_find_finally (vm_frame_ctx_t *frame_ctx_p, /**< frame context */ return false; } - byte_code_p = frame_ctx_p->byte_code_start_p + VM_GET_CONTEXT_END (vm_stack_top_p[-1]); + byte_code_p = frame_ctx_p->byte_code_start_p + context_end; if (context_type == VM_CONTEXT_TRY) { diff --git a/tests/jerry/fail/1/regression-test-issue-1597.js b/tests/jerry/fail/1/regression-test-issue-1597.js new file mode 100644 index 000000000..7e584436e --- /dev/null +++ b/tests/jerry/fail/1/regression-test-issue-1597.js @@ -0,0 +1,29 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +try { + throw 1 +} catch (e) { + + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + + throw 1 +}