Fix cleanup on error in Array.from (#3423)
This patch fixes #3420. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Zoltan Herczeg
parent
1a4972fc3f
commit
99fa823bab
@@ -321,14 +321,12 @@ iterator_cleanup:
|
||||
while (k < len)
|
||||
{
|
||||
/* 16.b */
|
||||
ecma_string_t *pk = ecma_new_ecma_string_from_uint32 (k);
|
||||
ecma_value_t k_value = ecma_op_object_get (array_like_obj_p, pk);
|
||||
ecma_deref_ecma_string (pk);
|
||||
ecma_value_t k_value = ecma_op_object_get_by_uint32_index (array_like_obj_p, k);
|
||||
|
||||
/* 16.c */
|
||||
if (ECMA_IS_VALUE_ERROR (k_value))
|
||||
{
|
||||
goto cleanup;
|
||||
goto construct_cleanup;
|
||||
}
|
||||
|
||||
ecma_value_t mapped_value;
|
||||
@@ -344,7 +342,7 @@ iterator_cleanup:
|
||||
/* 16.d.ii */
|
||||
if (ECMA_IS_VALUE_ERROR (mapped_value))
|
||||
{
|
||||
goto cleanup;
|
||||
goto construct_cleanup;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -362,7 +360,7 @@ iterator_cleanup:
|
||||
/* 16.g */
|
||||
if (ECMA_IS_VALUE_ERROR (set_status))
|
||||
{
|
||||
goto cleanup;
|
||||
goto construct_cleanup;
|
||||
}
|
||||
|
||||
/* 16.h */
|
||||
@@ -380,12 +378,15 @@ iterator_cleanup:
|
||||
/* 18. */
|
||||
if (ECMA_IS_VALUE_ERROR (set_status))
|
||||
{
|
||||
goto cleanup;
|
||||
goto construct_cleanup;
|
||||
}
|
||||
|
||||
/* 19. */
|
||||
ret_value = ecma_make_object_value (array_obj_p);
|
||||
ecma_deref_object (array_like_obj_p);
|
||||
return ecma_make_object_value (array_obj_p);
|
||||
|
||||
construct_cleanup:
|
||||
ecma_deref_object (array_obj_p);
|
||||
cleanup:
|
||||
ecma_deref_object (array_like_obj_p);
|
||||
return ret_value;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
try {
|
||||
Array.from.call(String, $);
|
||||
function $() {}
|
||||
assert(fasle);
|
||||
} catch (e) {
|
||||
assert(e instanceof TypeError);
|
||||
}
|
||||
Reference in New Issue
Block a user