Fixed TypedArray error handling

This patch fixes #2106. The problem was that the function always tried to transform the array-like object to TypedArray object even if there was an error during TypedArray creation.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2017-11-17 21:37:20 +01:00
committed by yichoi
parent 1dedc1b630
commit fe6c7b9b61
2 changed files with 73 additions and 56 deletions
@@ -417,9 +417,10 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
if (ECMA_IS_VALUE_ERROR (new_typedarray)) if (ECMA_IS_VALUE_ERROR (new_typedarray))
{ {
ret_value = ecma_copy_value (new_typedarray); ret_value = new_typedarray;
} }
else
{
ecma_object_t *new_typedarray_p = ecma_get_object_from_value (new_typedarray); ecma_object_t *new_typedarray_p = ecma_get_object_from_value (new_typedarray);
/* 17 */ /* 17 */
@@ -477,6 +478,7 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
{ {
ecma_deref_object (new_typedarray_p); ecma_deref_object (new_typedarray_p);
} }
}
ECMA_OP_TO_NUMBER_FINALIZE (len_number); ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value); ECMA_FINALIZE (len_value);
@@ -0,0 +1,15 @@
// 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.
new Float32Array({ length: 0x40000001 });