public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR93274-make-resolver-static-v2)] Fix a couple of memory leaks in the C++ frontend
@ 2020-01-27 10:08 Martin Liska
0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2020-01-27 10:08 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:bf91504dc23f17248df6302f7bad849f3ddedee7
commit bf91504dc23f17248df6302f7bad849f3ddedee7
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Jan 16 16:46:40 2020 -0500
Fix a couple of memory leaks in the C++ frontend
The leak in get_mapped_args is due to auto_vec not properly supporting
destructible elements in that auto_vec's destructor doesn't call the
destructors of its elements.
gcc/cp/ChangeLog:
* constraint.cc (get_mapped_args): Avoid using auto_vec
as a vector element. Release the vectors inside the lists
vector.
* parser.c (cp_literal_operator_id): Free the buffer.
Diff:
---
gcc/cp/ChangeLog | 7 +++++++
gcc/cp/constraint.cc | 7 ++++---
gcc/cp/parser.c | 1 +
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1609344..3d58238 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2020-01-22 Patrick Palka <ppalka@redhat.com>
+
+ * constraint.cc (get_mapped_args): Avoid using auto_vec
+ as a vector element. Release the vectors inside the lists
+ vector.
+ * parser.c (cp_literal_operator_id): Free the buffer.
+
2020-01-22 Jun Ma <JunMa@linux.alibaba.com>
* coroutines.cc (finish_co_await_expr): Add error check on return
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 128ab8a..823604a 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2431,7 +2431,7 @@ get_mapped_args (tree map)
list. Note that the list will be sparse (not all arguments supplied),
but instantiation is guaranteed to only use the parameters in the
mapping, so null arguments would never be used. */
- auto_vec< auto_vec<tree> > lists (count);
+ auto_vec< vec<tree> > lists (count);
lists.quick_grow_cleared (count);
for (tree p = map; p; p = TREE_CHAIN (p))
{
@@ -2440,7 +2440,7 @@ get_mapped_args (tree map)
template_parm_level_and_index (TREE_VALUE (p), &level, &index);
/* Insert the argument into its corresponding position. */
- auto_vec<tree> &list = lists[level - 1];
+ vec<tree> &list = lists[level - 1];
if (index >= (int)list.length ())
list.safe_grow_cleared (index + 1);
list[index] = TREE_PURPOSE (p);
@@ -2450,11 +2450,12 @@ get_mapped_args (tree map)
tree args = make_tree_vec (lists.length ());
for (unsigned i = 0; i != lists.length (); ++i)
{
- auto_vec<tree> &list = lists[i];
+ vec<tree> &list = lists[i];
tree level = make_tree_vec (list.length ());
for (unsigned j = 0; j < list.length(); ++j)
TREE_VEC_ELT (level, j) = list[j];
SET_TMPL_ARGS_LEVEL (args, i + 1, level);
+ list.release ();
}
SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (args, 0);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index caafbef..ea32df9 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -15372,6 +15372,7 @@ cp_literal_operator_id (const char* name)
+ strlen (name) + 10);
sprintf (buffer, UDLIT_OP_ANSI_FORMAT, name);
identifier = get_identifier (buffer);
+ XDELETEVEC (buffer);
return identifier;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-01-27 10:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-27 10:08 [gcc(refs/users/marxin/heads/PR93274-make-resolver-static-v2)] Fix a couple of memory leaks in the C++ frontend Martin Liska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).