Commit 38595590 authored by Xavier Thompson's avatar Xavier Thompson

Fix refcounting when iterating over temporary cypclass values

parent eb138d17
......@@ -2944,6 +2944,8 @@ class CppIteratorNode(ExprNode):
code.putln("%s = %s%s;" % (self.cpp_sequence_cname,
"&" if temp_type.is_ptr else "",
self.sequence.move_result_rhs()))
if sequence_type.is_cyp_class:
code.put_incref(self.cpp_sequence_cname, sequence_type)
code.putln("%s = %s%sbegin();" % (self.result(), self.cpp_sequence_cname,
self.cpp_attribute_op))
......@@ -2959,6 +2961,11 @@ class CppIteratorNode(ExprNode):
self.result()))
code.putln("++%s;" % self.result())
def generate_disposal_code(self, code):
if self.cpp_sequence_cname and self.sequence.type.is_cyp_class:
code.put_decref(self.cpp_sequence_cname, self.sequence.type)
super(CppIteratorNode, self).generate_disposal_code(code)
def free_temps(self, code):
if self.cpp_sequence_cname:
code.funcstate.release_temp(self.cpp_sequence_cname)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment