cython
changeset 1585:66ce58e9ff83
Fix memleak in exception handling code (#162)
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sun Dec 14 02:58:32 2008 -0800 (15 months ago) |
| parents | af66b0e9b436 |
| children | 4a96e1aff2d4 |
| files | Cython/Compiler/Nodes.py |
line diff
1.1 --- a/Cython/Compiler/Nodes.py Sun Dec 14 02:47:49 2008 -0800
1.2 +++ b/Cython/Compiler/Nodes.py Sun Dec 14 02:58:32 2008 -0800
1.3 @@ -3883,6 +3883,7 @@
1.4 except_end_label = code.new_label('exception_handled')
1.5 except_error_label = code.new_label('except_error')
1.6 except_return_label = code.new_label('except_return')
1.7 + try_return_label = code.new_label('try_return')
1.8 try_end_label = code.new_label('try')
1.9
1.10 code.putln("{")
1.11 @@ -3892,6 +3893,7 @@
1.12 ', '.join(['&%s' % var for var in Naming.exc_save_vars]))
1.13 code.putln(
1.14 "/*try:*/ {")
1.15 + code.return_label = try_return_label
1.16 self.body.generate_execution_code(code)
1.17 code.putln(
1.18 "}")
1.19 @@ -3906,6 +3908,11 @@
1.20 for var in Naming.exc_save_vars:
1.21 code.put_xdecref_clear(var, py_object_type)
1.22 code.put_goto(try_end_label)
1.23 + if code.label_used(try_return_label):
1.24 + code.put_label(try_return_label)
1.25 + for var in Naming.exc_save_vars:
1.26 + code.put_xdecref_clear(var, py_object_type)
1.27 + code.put_goto(old_return_label)
1.28 code.put_label(our_error_label)
1.29 code.put_var_xdecrefs_clear(self.cleanup_list)
1.30 for except_clause in self.except_clauses:
