Skip to content

Commit b46535c

Browse files
authored
Add strict flag check for ecma_op_object_put_apply_receiver (#4450)
This patch fixes #4441. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 363bc92 commit b46535c

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

jerry-core/ecma/operations/ecma-objects.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,11 @@ ecma_op_object_put_apply_receiver (ecma_value_t receiver, /**< receiver */
11641164

11651165
/* 5.e.iv */
11661166
result = ecma_op_object_define_own_property (receiver_obj_p, property_name_p, &prop_desc);
1167+
1168+
if (JERRY_UNLIKELY (ecma_is_value_false (result)) && is_throw)
1169+
{
1170+
result = ecma_raise_type_error (ECMA_ERR_MSG ("Proxy trap returned falsish"));
1171+
}
11671172
}
11681173

11691174
ecma_free_property_descriptor (&prop_desc);
@@ -1184,7 +1189,14 @@ ecma_op_object_put_apply_receiver (ecma_value_t receiver, /**< receiver */
11841189
| ECMA_PROP_IS_WRITABLE_DEFINED
11851190
| ECMA_PROP_IS_VALUE_DEFINED);
11861191
desc.value = value;
1187-
return ecma_proxy_object_define_own_property (receiver_obj_p, property_name_p, &desc);
1192+
ecma_value_t ret_value = ecma_proxy_object_define_own_property (receiver_obj_p, property_name_p, &desc);
1193+
1194+
if (JERRY_UNLIKELY (ecma_is_value_false (ret_value)) && is_throw)
1195+
{
1196+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Proxy trap returned falsish"));
1197+
}
1198+
1199+
return ret_value;
11881200
}
11891201
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
11901202

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 get = [];
16+
var constructor = Function();
17+
constructor[Symbol.species] = Object;
18+
var p = new Proxy({ constructor: constructor, flags: '', exec: function() { return /\ua796/iu; } }, { defineProperty: function(o, k) { get.push(k); return o[k]; }});
19+
20+
try {
21+
RegExp.prototype[Symbol.split].call(p, 7996);
22+
assert(false);
23+
} catch (e) {
24+
assert(e instanceof TypeError);
25+
}

0 commit comments

Comments
 (0)