From 4c06e46c76acc8f464833ea21ad2f44c48f1d2bb Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 29 Jan 2009 22:48:02 +0100 Subject: [PATCH] fix memory leak in EvalWithTempExprNode --- Cython/Compiler/UtilNodes.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/UtilNodes.py b/Cython/Compiler/UtilNodes.py index 497ce7e5..11256574 100644 --- a/Cython/Compiler/UtilNodes.py +++ b/Cython/Compiler/UtilNodes.py @@ -164,14 +164,18 @@ class EvalWithTempExprNode(ExprNodes.NewTempExprNode): def generate_evaluation_code(self, code): self.temp_expression.generate_evaluation_code(code) - if self.temp_expression.is_temp: + result_in_temp = self.temp_expression.result_in_temp() + temp_type = self.temp_expression.type + if result_in_temp: temp = self.temp_expression.result() else: self.temp_expression.make_owned_reference(code) temp = code.funcstate.allocate_temp( - self.temp_expression.type, manage_ref=True) + temp_type, manage_ref=True) code.putln("%s = %s;" % (temp, self.temp_expression.result())) self.lazy_temp.result_code = temp self.subexpression.generate_evaluation_code(code) - if not self.temp_expression.is_temp: + if not result_in_temp: + if temp_type.is_pyobject: + code.put_decref_clear(temp, temp_type) code.funcstate.release_temp(temp) -- 2.26.2