Fix leak in try-break.
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 26 Feb 2009 07:44:24 +0000 (23:44 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 26 Feb 2009 07:44:24 +0000 (23:44 -0800)
Cython/Compiler/Code.py
Cython/Compiler/Nodes.py

index 356736dca34999e66ca1038736e05755e7e2b7bb..cfc59bd8e414341eba93ff69b38ca965845a727b 100644 (file)
@@ -73,8 +73,8 @@ class FunctionState(object):
     def new_loop_labels(self):
         old_labels = self.get_loop_labels()
         self.set_loop_labels(
-            (self.new_label(), 
-             self.new_label()))
+            (self.new_label("continue"), 
+             self.new_label("break")))
         return old_labels
     
     def get_all_labels(self):
index f67f3e9466a087d6ef01c2a141a65847dd745feb..27ca2bf12cdecf9501d4323e428afb392b2f3ad8 100644 (file)
@@ -4221,11 +4221,20 @@ class ExceptClauseNode(Node):
 
         old_exc_vars = code.funcstate.exc_vars
         code.funcstate.exc_vars = self.exc_vars
+        old_break_label = code.break_label
+        code.break_label = code.new_label('except_break')
         self.body.generate_execution_code(code)
         code.funcstate.exc_vars = old_exc_vars
         for var in self.exc_vars:
             code.putln("__Pyx_DECREF(%s); %s = 0;" % (var, var))
         code.put_goto(end_label)
+        
+        if code.label_used(code.break_label):
+            code.put_label(code.break_label)
+            for var in self.exc_vars:
+                code.putln("__Pyx_DECREF(%s); %s = 0;" % (var, var))
+            code.put_goto(old_break_label)
+        code.break_label = old_break_label
         code.putln(
             "}")