[patch] regmove.c: Fix memory leak.

Kazu Hirata kazu@cs.umass.edu
Fri Dec 10 20:19:00 GMT 2004


Hi,

Attached is a patch to fix memory leak.

In combine_stack_adjustments_for_block, we set memlist to NULL if we
free it during the course of the function.  So, if memlist isn't NULL
at the end of the function, that means we haven't freed it yet.

The patch frees memlist if it hasn't been freed.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-12-10  Kazu Hirata  <kazu@cs.umass.edu>

	* regmove.c (combine_stack_adjustments_for_block): Free
	memlist if it hasn't been freed.

Index: regmove.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regmove.c,v
retrieving revision 1.165
diff -u -d -p -r1.165 regmove.c
--- regmove.c	16 Nov 2004 21:11:33 -0000	1.165
+++ regmove.c	10 Dec 2004 07:47:53 -0000
@@ -2457,4 +2457,7 @@ combine_stack_adjustments_for_block (bas
 
   if (last_sp_set && last_sp_adjust == 0)
     delete_insn (last_sp_set);
+
+  if (memlist)
+    free_csa_memlist (memlist);
 }



More information about the Gcc-patches mailing list