Skip to content

Commit be273d8

Browse files
committed
When the same value is assigned to a property, and its reference
counter is one, dereferencing the value frees its allocated memory. In this case we return early. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent e4b0d81 commit be273d8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

jerry-core/ecma/base/ecma-helpers-value.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,11 @@ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
660660
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0,
661661
ecma_type_direct_must_be_zero_for_the_next_check);
662662

663+
if (*value_p == ecma_value)
664+
{
665+
return;
666+
}
667+
663668
if (ecma_get_value_type_field (ecma_value || *value_p) == ECMA_TYPE_DIRECT)
664669
{
665670
*value_p = ecma_value;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2016 Samsung Electronics Co., Ltd.
2+
// Copyright 2016 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
try { new (this.$)(new (this.RegExp)().ignoreCase).$ () } catch($){}
17+
try { new (this.String)() .constructor.prototype.match() } catch($){}
18+
try { this.RegExp().compile() } catch($){}
19+
try { this.$(this.RegExp.prototype .compile (this.RegExp.prototype)) } catch($){}

0 commit comments

Comments
 (0)