diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c index 0b0fecf38..d58a5bab9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c @@ -1522,7 +1522,8 @@ ecma_builtin_helper_split_match (ecma_value_t input_string, /**< first argument ret_value = ecma_regexp_exec_helper (regexp_value, ecma_make_string_value (substr_str_p), true); - if (!ecma_is_value_null (ret_value)) + if (!ECMA_IS_VALUE_ERROR (ret_value) + && !ecma_is_value_null (ret_value)) { ecma_object_t *obj_p = ecma_get_object_from_value (ret_value); ecma_string_t *magic_index_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX); diff --git a/tests/jerry/regression-test-issue-1546.js b/tests/jerry/regression-test-issue-1546.js new file mode 100644 index 000000000..2fb01edec --- /dev/null +++ b/tests/jerry/regression-test-issue-1546.js @@ -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. + +String.prototype.split(RegExp.prototype);