Skip to content

Commit 358101f

Browse files
authored
Fix string dereference in ecma_op_create_dynamic_function (#3873)
Fixes #3862 JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi [email protected]
1 parent ba4e3a4 commit 358101f

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-reflect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ ecma_builtin_reflect_dispatch_routine (uint16_t builtin_routine_id, /**< built-i
179179

180180
ecma_object_t *target_p = ecma_get_object_from_value (arguments_list[0]);
181181

182-
/* 2. new_target_p is not supported for now*/
182+
/* 2. */
183183
ecma_object_t *new_target_p = target_p;
184184

185185
if (arguments_number > 2)

jerry-core/ecma/operations/ecma-function-object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ ecma_op_create_dynamic_function (const ecma_value_t *arguments_list_p, /**< argu
419419
if (JERRY_UNLIKELY (proto == NULL))
420420
{
421421
ecma_bytecode_deref (bytecode_data_p);
422+
ecma_deref_ecma_string (arguments_str_p);
423+
ecma_deref_ecma_string (function_body_str_p);
422424
return ECMA_VALUE_ERROR;
423425
}
424426
#endif /* ENABLED (JERRY_ES2015) */

tests/jerry/es2015/reflect-construct.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ function DogClass () {
5151

5252
var obj1 = Reflect.construct (CatClass, args, DogClass);
5353
assert (obj1.name === 'Cat');
54-
// assert (!(ob1 instanceof CatClass)); This is true because new target is not supported yet
55-
// assert (obj1 instanceof DogClass); This is false because new target is not supported yet
54+
assert (!(obj1 instanceof CatClass));
55+
assert (obj1 instanceof DogClass);
5656

5757
try {
5858
Reflect.construct (func1, 5, 5);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var target = function() {};
16+
var handler = {
17+
get() {
18+
if ($);
19+
}
20+
};
21+
22+
var o = new Proxy(target, handler);
23+
24+
try {
25+
Reflect.construct(Function, ['c'], o);
26+
assert(false);
27+
} catch (e) {
28+
assert(e instanceof ReferenceError);
29+
}

0 commit comments

Comments
 (0)