From 1b06fcb0c9ec1110f4d6eb1dacf9c41222346f04 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 3 Feb 2021 09:15:35 +0100 Subject: [PATCH] more memory leak fixes This fixes more memory leaks as discovered by building 521.wrf_r. 2021-02-03 Richard Biener * lto-streamer.c (lto_get_section_name): Free temporary buffer. * tree-loop-distribution.c (loop_distribution::merge_dep_scc_partitions): Free edge data. --- gcc/lto-streamer.c | 8 ++++++-- gcc/tree-loop-distribution.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index 36e673514a7..84db5eb944d 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -106,6 +106,7 @@ lto_get_section_name (int section_type, const char *name, const char *add; char post[32]; const char *sep; + char *buffer = NULL; if (section_type == LTO_section_function_body) { @@ -113,7 +114,7 @@ lto_get_section_name (int section_type, const char *name, if (name[0] == '*') name++; - char *buffer = (char *)xmalloc (strlen (name) + 32); + buffer = (char *)xmalloc (strlen (name) + 32); sprintf (buffer, "%s.%d", name, node_order); add = buffer; @@ -138,7 +139,10 @@ lto_get_section_name (int section_type, const char *name, sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, f->id); else sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, get_random_seed (false)); - return concat (section_name_prefix, sep, add, post, NULL); + char *res = concat (section_name_prefix, sep, add, post, NULL); + if (buffer) + free (buffer); + return res; } diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index bb15fd3723f..7ee19fc8677 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -2358,6 +2358,7 @@ loop_distribution::merge_dep_scc_partitions (struct graph *rdg, sort_partitions_by_post_order (pg, partitions); gcc_assert (partitions->length () == (unsigned)num_sccs); free_partition_graph_vdata (pg); + for_each_edge (pg, free_partition_graph_edata_cb, NULL); free_graph (pg); } -- 2.30.2