From 87441635e1e76a7febe94f88187667200616d63c Mon Sep 17 00:00:00 2001 From: Daniel Balla Date: Mon, 16 Sep 2019 12:32:56 +0300 Subject: [PATCH] Add error check to VM_OC_CLASS_INHERITANCE (#3122) ecma_op_object_get_by_magic_id can throw an exception Fixes #3121 JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu --- jerry-core/vm/vm.c | 7 +++++++ tests/jerry/fail/regresssion-test-issue-3121.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/jerry/fail/regresssion-test-issue-3121.js diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index 20bb1dd64..0cfac9212 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -1405,6 +1405,13 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ { ecma_value_t super_prototype_value = ecma_op_object_get_by_magic_id (super_class_p, LIT_MAGIC_STRING_PROTOTYPE); + + if (ECMA_IS_VALUE_ERROR (super_prototype_value)) + { + result = super_prototype_value; + goto error; + } + if (ecma_get_object_type (super_class_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION && !ecma_is_value_object (super_prototype_value)) { diff --git a/tests/jerry/fail/regresssion-test-issue-3121.js b/tests/jerry/fail/regresssion-test-issue-3121.js new file mode 100644 index 000000000..d6bc98e66 --- /dev/null +++ b/tests/jerry/fail/regresssion-test-issue-3121.js @@ -0,0 +1,17 @@ +// 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. + +var Base = function ( ) { }.bind( ); +Object.defineProperty ( Base , 'prototype' , { get : function ( ) {$} } ); +class C extends Base { }