From 40370fbba8a0b59324c5273c5d743bf78841aadb Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Wed, 25 Feb 2009 23:44:24 -0800 Subject: [PATCH] Fix leak in try-break. --- Cython/Compiler/Code.py | 4 ++-- Cython/Compiler/Nodes.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 356736dc..cfc59bd8 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -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): diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index f67f3e94..27ca2bf1 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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( "}") -- 2.26.2