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 09/15] fix memory leak in scop-detection


From: Sebastian Pop <s.pop@samsung.com>

        * graphite-scop-detection.c
        (scop_detection::harmful_loop_in_region): Free dom and loops.
        (scop_detection::loop_body_is_valid_scop): Free bbs.
---
 gcc/graphite-scop-detection.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index be33be3..a0c630b 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1088,7 +1088,11 @@ scop_detection::harmful_loop_in_region (sese_l scop) const
 	     any loop fully contained in the scop: other bbs are checked below
 	     in loop_is_valid_in_scop.  */
 	  if (harmful_stmt_in_bb (scop, bb))
-	    return true;
+	    {
+	      dom.release ();
+	      BITMAP_FREE (loops);
+	      return true;
+	    }
 	}
 
     }
@@ -1104,13 +1108,14 @@ scop_detection::harmful_loop_in_region (sese_l scop) const
 
       if (!loop_is_valid_in_scop (loop, scop))
 	{
+	  dom.release ();
 	  BITMAP_FREE (loops);
 	  return true;
 	}
     }
 
-  BITMAP_FREE (loops);
   dom.release ();
+  BITMAP_FREE (loops);
   return false;
 }
 
@@ -1503,7 +1508,10 @@ scop_detection::loop_body_is_valid_scop (loop_p loop, sese_l scop) const
       basic_block bb = bbs[i];
 
       if (harmful_stmt_in_bb (scop, bb))
-	return false;
+	{
+	  free (bbs);
+	  return false;
+	}
     }
   free (bbs);
 
-- 
2.5.0


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