Commit 5858d358 authored by Robert Bradshaw's avatar Robert Bradshaw Committed by GitHub

Merge pull request #507 from SyamGadde/memoryviewleak

Fix refcounts for transposed memoryview slices.
parents cff4b8eb b3b95252
...@@ -728,6 +728,8 @@ class ExprNode(Node): ...@@ -728,6 +728,8 @@ class ExprNode(Node):
elif self.type.is_memoryviewslice: elif self.type.is_memoryviewslice:
code.put_xdecref_memoryviewslice( code.put_xdecref_memoryviewslice(
self.result(), have_gil=not self.in_nogil_context) self.result(), have_gil=not self.in_nogil_context)
code.putln("%s.memview = NULL;" % self.result())
code.putln("%s.data = NULL;" % self.result())
else: else:
# Already done if self.is_temp # Already done if self.is_temp
self.generate_subexpr_disposal_code(code) self.generate_subexpr_disposal_code(code)
...@@ -6655,9 +6657,7 @@ class AttributeNode(ExprNode): ...@@ -6655,9 +6657,7 @@ class AttributeNode(ExprNode):
return return
code.putln("%s = %s;" % (self.result(), self.obj.result())) code.putln("%s = %s;" % (self.result(), self.obj.result()))
if self.obj.is_name or (self.obj.is_attribute and code.put_incref_memoryviewslice(self.result(), have_gil=True)
self.obj.is_memslice_transpose):
code.put_incref_memoryviewslice(self.result(), have_gil=True)
T = "__pyx_memslice_transpose(&%s) == 0" T = "__pyx_memslice_transpose(&%s) == 0"
code.putln(code.error_goto_if(T % self.result(), self.pos)) code.putln(code.error_goto_if(T % self.result(), self.pos))
...@@ -6680,10 +6680,10 @@ class AttributeNode(ExprNode): ...@@ -6680,10 +6680,10 @@ class AttributeNode(ExprNode):
def generate_disposal_code(self, code): def generate_disposal_code(self, code):
if self.is_temp and self.type.is_memoryviewslice and self.is_memslice_transpose: if self.is_temp and self.type.is_memoryviewslice and self.is_memslice_transpose:
# mirror condition for putting the memview incref here: # mirror condition for putting the memview incref here:
if self.obj.is_name or (self.obj.is_attribute and code.put_xdecref_memoryviewslice(
self.obj.is_memslice_transpose): self.result(), have_gil=True)
code.put_xdecref_memoryviewslice( code.putln("%s.memview = NULL;" % self.result())
self.result(), have_gil=True) code.putln("%s.data = NULL;" % self.result())
else: else:
ExprNode.generate_disposal_code(self, code) ExprNode.generate_disposal_code(self, code)
......
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