more memory leak fixes
authorRichard Biener <rguenther@suse.de>
Wed, 3 Feb 2021 08:15:35 +0000 (09:15 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 3 Feb 2021 09:04:13 +0000 (10:04 +0100)
This fixes more memory leaks as discovered by building 521.wrf_r.

2021-02-03  Richard Biener  <rguenther@suse.de>

* 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
gcc/tree-loop-distribution.c

index 36e6735..84db5eb 100644 (file)
@@ -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;
 }
 
 
index bb15fd3..7ee19fc 100644 (file)
@@ -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);
 }