Skip to content

Commit

Permalink
Add error check to VM_OC_CLASS_INHERITANCE
Browse files Browse the repository at this point in the history
ecma_op_object_get_by_magic_id can throw an exception

Fixes jerryscript-project#3121

JerryScript-DCO-1.0-Signed-off-by: Daniel Balla [email protected]
  • Loading branch information
Daniel Balla committed Sep 13, 2019
1 parent 6e79bb1 commit 682041a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jerry-core/vm/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
17 changes: 17 additions & 0 deletions tests/jerry/fail/regresssion-test-issue-3121.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright JS Foundation and other contributors, http:https://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:https://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 { }

0 comments on commit 682041a

Please sign in to comment.