Skip to content

Commit 685d8b3

Browse files
rerobikaDaniel Balla
authored andcommitted
Fix JERRY_CONTEXT (error_value) handling during ecma_builtin_promise_reject_abrupt (#2519)
Fixes #2489. Co-authored-by: Daniel Balla <dballa@inf.u-szeged.hu> JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
1 parent b97f5ff commit 685d8b3

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ ecma_builtin_promise_reject_or_resolve (ecma_value_t this_arg, /**< "this" argum
125125
inline static ecma_value_t
126126
ecma_builtin_promise_reject_abrupt (ecma_value_t capability) /**< reject description */
127127
{
128+
ecma_raise_type_error (ECMA_ERR_MSG ("Second argument is not an array."));
128129
ecma_value_t reason = JERRY_CONTEXT (error_value);
129130
ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
130131
ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), reject_str_p);
@@ -134,6 +135,7 @@ ecma_builtin_promise_reject_abrupt (ecma_value_t capability) /**< reject descrip
134135
&reason,
135136
1);
136137
ecma_free_value (reject);
138+
ecma_free_value (reason);
137139

138140
if (ECMA_IS_VALUE_ERROR (call_ret))
139141
{
@@ -576,11 +578,8 @@ ecma_builtin_promise_race_or_all (ecma_value_t this_arg, /**< 'this' argument */
576578
if (!ecma_is_value_object (array)
577579
|| ecma_get_object_type (ecma_get_object_from_value (array)) != ECMA_OBJECT_TYPE_ARRAY)
578580
{
579-
ecma_raise_type_error (ECMA_ERR_MSG ("Second argument is not an array."));
580581
ret = ecma_builtin_promise_reject_abrupt (capability);
581-
ecma_free_value (JERRY_CONTEXT (error_value));
582582
ecma_free_value (capability);
583-
584583
return ret;
585584
}
586585

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
Object.defineProperty(Object.prototype, 0, {'get': function() { throw $ }});
16+
Promise.all();

0 commit comments

Comments
 (0)