Skip to content

Commit 0b54dd0

Browse files
committed
Fix value release in ecma_builtin_regexp_dispatch_helper
JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi [email protected]
1 parent 62730f2 commit 0b54dd0

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ ecma_builtin_regexp_dispatch_helper (const ecma_value_t *arguments_list_p, /**<
131131

132132
if (ECMA_IS_VALUE_ERROR (flags_value))
133133
{
134+
ecma_free_value (pattern_value);
134135
return flags_value;
135136
}
136137
}
@@ -151,6 +152,12 @@ ecma_builtin_regexp_dispatch_helper (const ecma_value_t *arguments_list_p, /**<
151152

152153
if (JERRY_UNLIKELY (new_target_obj_p == NULL))
153154
{
155+
if (pattern_is_regexp)
156+
{
157+
ecma_free_value (pattern_value);
158+
ecma_free_value (flags_value);
159+
}
160+
154161
return ECMA_VALUE_ERROR;
155162
}
156163

@@ -171,6 +178,12 @@ ecma_builtin_regexp_dispatch_helper (const ecma_value_t *arguments_list_p, /**<
171178
}
172179
#endif /* ENABLED (JERRY_ES2015) */
173180

181+
if (pattern_is_regexp)
182+
{
183+
ecma_free_value (pattern_value);
184+
ecma_free_value (flags_value);
185+
}
186+
174187
if (ECMA_IS_VALUE_ERROR (ret_value))
175188
{
176189
ecma_deref_object (new_target_obj_p);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var obj = {
16+
get source() {
17+
return "Iam"
18+
},
19+
[Symbol.match]: true
20+
}
21+
22+
var regexp = new RegExp(obj);
23+
print(regexp.source === "Iam");

0 commit comments

Comments
 (0)