diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 0804a263bc..b2b0f27591 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -381,16 +381,17 @@ ecma_op_create_regexp_from_pattern (ecma_object_t *regexp_obj_p, /**< RegExp obj const re_compiled_code_t *bc_p = NULL; ecma_value_t ret_value = re_compile_bytecode (&bc_p, pattern_str_p, flags); - ecma_deref_ecma_string (pattern_str_p); if (ECMA_IS_VALUE_ERROR (ret_value)) { + ecma_deref_ecma_string (pattern_str_p); return ret_value; } JERRY_ASSERT (ecma_is_value_empty (ret_value)); ecma_op_regexp_initialize (regexp_obj_p, bc_p, pattern_str_p, flags); + ecma_deref_ecma_string (pattern_str_p); return ecma_make_object_value (regexp_obj_p); } /* ecma_op_create_regexp_from_pattern */ diff --git a/tests/jerry/regression-test-issue-3748-3749.js b/tests/jerry/regression-test-issue-3748-3749.js new file mode 100644 index 0000000000..c6b0638080 --- /dev/null +++ b/tests/jerry/regression-test-issue-3748-3749.js @@ -0,0 +1,19 @@ +// 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 to trigger the gc a few times*/ +for (var i = 0; i < 2; i++) +{ + new RegExp(32.2, "g") +}