Commit aa44fd4d authored by gsamain's avatar gsamain

Make del unlock object only if it was locked (segfault if done in with locked bloc)

parent 2de3b269
...@@ -6113,6 +6113,7 @@ class DelStatNode(StatNode): ...@@ -6113,6 +6113,7 @@ class DelStatNode(StatNode):
child_attrs = ["args"] child_attrs = ["args"]
ignore_nonexisting = False ignore_nonexisting = False
was_locked = False
def analyse_declarations(self, env): def analyse_declarations(self, env):
for arg in self.args: for arg in self.args:
...@@ -6127,6 +6128,8 @@ class DelStatNode(StatNode): ...@@ -6127,6 +6128,8 @@ class DelStatNode(StatNode):
error(arg.pos, "Deletion of global C variable") error(arg.pos, "Deletion of global C variable")
elif arg.type.is_ptr and arg.type.base_type.is_cpp_class or arg.type.is_cyp_class: elif arg.type.is_ptr and arg.type.base_type.is_cpp_class or arg.type.is_cyp_class:
self.cpp_check(env) self.cpp_check(env)
if arg.type.is_cyp_class:
self.was_locked = arg.needs_rlock() or arg.needs_wlock()
elif arg.type.is_cpp_class: elif arg.type.is_cpp_class:
error(arg.pos, "Deletion of non-heap C++ object") error(arg.pos, "Deletion of non-heap C++ object")
elif arg.is_subscript and arg.base.type is Builtin.bytearray_type: elif arg.is_subscript and arg.base.type is Builtin.bytearray_type:
...@@ -6157,7 +6160,7 @@ class DelStatNode(StatNode): ...@@ -6157,7 +6160,7 @@ class DelStatNode(StatNode):
arg.generate_disposal_code(code) arg.generate_disposal_code(code)
elif arg.type.is_cyp_class: elif arg.type.is_cyp_class:
arg.generate_evaluation_code(code) arg.generate_evaluation_code(code)
if arg.type.lock_mode == "autolock": if arg.type.lock_mode == "autolock" and self.was_locked:
code.putln("Cy_UNLOCK(%s);" % arg.result()) code.putln("Cy_UNLOCK(%s);" % arg.result())
code.putln("Cy_DECREF(%s);" % arg.result()) code.putln("Cy_DECREF(%s);" % arg.result())
code.putln("%s = NULL;" % arg.result()) code.putln("%s = NULL;" % arg.result())
......
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