Skip to content

Commit b3b1dfd

Browse files
authored
Tagged template object references should be released only in post_processing (#3495)
This patch fixes #3483. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
1 parent 2960dff commit b3b1dfd

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

jerry-core/parser/js/js-parser-tagged-template-literal.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ parser_tagged_template_literal_finalize (ecma_object_t *template_obj_p, /**< tem
141141
{
142142
parser_tagged_template_literal_freeze_array (template_obj_p);
143143
parser_tagged_template_literal_freeze_array (raw_strings_p);
144-
145-
ecma_deref_object (template_obj_p);
146144
} /* parser_tagged_template_literal_finalize */
147145
#endif /* ENABLED (JERRY_ES2015) */
148146

jerry-core/parser/js/js-parser.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,14 @@ parser_post_processing (parser_context_t *context_p) /**< context */
16141614
}
16151615

16161616
tagged_base_p[-1] = (ecma_value_t) context_p->tagged_template_literal_cp;
1617+
1618+
ecma_collection_t *collection_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
1619+
context_p->tagged_template_literal_cp);
1620+
1621+
for (uint32_t i = 0; i < collection_p->item_count; i++)
1622+
{
1623+
ecma_free_value (collection_p->buffer_p[i]);
1624+
}
16171625
}
16181626
#endif /* ENABLED (JERRY_ES2015) */
16191627

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
function assertThrows(src) {
16+
try {
17+
eval(src);
18+
assert(false);
19+
} catch (e) {
20+
assert(e instanceof SyntaxError);
21+
}
22+
}
23+
24+
assertThrows('Setting `o.bar` to');
25+
assertThrows('Setting `o.bar`; Setting `o.bar` to');
26+
assertThrows('Setting `o.bar`; Setting `o.bar`; Setting `o.bar` to');

0 commit comments

Comments
 (0)