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]

Fix cse memory leak



cse.c can leak memory due to early return paths out of cse_basic_block.  Wee,
we're having fun now!



	* cse.c (cse_basic_block): Free qty_table consistently.

Index: cse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cse.c,v
retrieving revision 1.117
diff -c -3 -p -r1.117 cse.c
*** cse.c	1999/12/09 14:38:11	1.117
--- cse.c	1999/12/13 04:30:19
*************** cse_basic_block (from, to, next_branch, 
*** 6961,6967 ****
        if (simplejump_p (insn))
  	{
  	  if (to == 0)
! 	    return 0;
  
  	  if (JUMP_LABEL (insn) == to)
  	    to_usage = 1;
--- 6961,6970 ----
        if (simplejump_p (insn))
  	{
  	  if (to == 0)
! 	    {
! 	      free (qty_table + max_reg);
! 	      return 0;
! 	    }
  
  	  if (JUMP_LABEL (insn) == to)
  	    to_usage = 1;
*************** cse_basic_block (from, to, next_branch, 
*** 6993,7005 ****
  
  	  /* If TO was the last insn in the function, we are done.  */
  	  if (insn == 0)
! 	    return 0;
  
  	  /* If TO was preceded by a BARRIER we are done with this block
  	     because it has no continuation.  */
  	  prev = prev_nonnote_insn (to);
  	  if (prev && GET_CODE (prev) == BARRIER)
! 	    return insn;
  
  	  /* Find the end of the following block.  Note that we won't be
  	     following branches in this case.  */
--- 6996,7014 ----
  
  	  /* If TO was the last insn in the function, we are done.  */
  	  if (insn == 0)
! 	    {
! 	      free (qty_table + max_reg);
! 	      return 0;
! 	    }
  
  	  /* If TO was preceded by a BARRIER we are done with this block
  	     because it has no continuation.  */
  	  prev = prev_nonnote_insn (to);
  	  if (prev && GET_CODE (prev) == BARRIER)
! 	    {
! 	      free (qty_table + max_reg);
! 	      return insn;
! 	    }
  
  	  /* Find the end of the following block.  Note that we won't be
  	     following branches in this case.  */





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