Add missing error check in ecma_builtin_promise_do_race (#2546)

Fixes #2544.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik 2018-10-03 11:39:43 +02:00 committed by László Langó
parent e12d015bd2
commit abf22597e5
2 changed files with 23 additions and 0 deletions

View File

@ -231,6 +231,13 @@ ecma_builtin_promise_do_race (ecma_value_t array, /**< the array for race */
ecma_value_t array_item = ecma_op_object_get (array_p, index_to_str_p);
ecma_deref_ecma_string (index_to_str_p);
/* f. */
if (ECMA_IS_VALUE_ERROR (array_item))
{
ret = array_item;
break;
}
/* h. */
ecma_value_t next_promise = ecma_builtin_promise_resolve (ctor, array_item);
ecma_free_value (array_item);

View File

@ -0,0 +1,16 @@
// 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.
Object.defineProperty(Array.prototype, 0, { get : function () { throw $; } });
Promise.race([ , this]).then(Error);