This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix memory leak within ipa_inline


ipa-inline.c:ipa_inline leaks "order" when optimizations are disabled.
This potentially becomes significant in my JIT branch since the
compilation code could be invoked many times within one process.

Bootstrapped and regtested against trunk on x86_64-unknown-linux.

OK for trunk?

(Seen using valgrind; I've already committed this on my dmalcolm/jit
branch as:
http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=8c61655effbb29cba2cc342c35bd47a6dda2df16
)

commit 090cc42be462de08068014ce371fb68d15945f8e
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Wed Oct 9 13:50:23 2013 -0400

    ipa-inline.c:ipa_inline: Fix leak of "order" when optimizations are disabled.
    
    gcc/
    	* ipa-inline.c (ipa_inline): Fix leak of "order" when
    	optimizations are disabled.

diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index f51178b..f93cc45 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1962,8 +1962,7 @@ ipa_inline (void)
 {
   struct cgraph_node *node;
   int nnodes;
-  struct cgraph_node **order =
-    XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
+  struct cgraph_node **order;
   int i;
   int cold;
   bool remove_functions = false;
@@ -1971,6 +1970,8 @@ ipa_inline (void)
   if (!optimize)
     return 0;
 
+  order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
+
   if (in_lto_p && optimize)
     ipa_update_after_lto_read ();
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]