diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2016-03-24 07:28:29 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2016-03-24 07:28:29 +0100 |
commit | 1adf6cc73e65e0eefe2f426e3ff5b03f97044128 (patch) | |
tree | 3374263bc1a978261649cf4b9aa9a4be1b2cf171 | |
parent | d42a4d7d037272a6e365498ee36091b50d9377c4 (diff) | |
download | cython-1adf6cc73e65e0eefe2f426e3ff5b03f97044128.tar.gz |
fix reference leak in closure when reassigning to "*args" argument
-rw-r--r-- | Cython/Compiler/Nodes.py | 2 | ||||
-rw-r--r-- | tests/run/closure_leak_1.pyx | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 0dac82f97..02fc4f196 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1915,7 +1915,7 @@ class FuncDefNode(StatNode, BlockNode): elif is_cdef and entry.type.is_memoryviewslice and len(entry.cf_assignments) > 1: code.put_incref_memoryviewslice(entry.cname, have_gil=code.funcstate.gil_owned) for entry in lenv.var_entries: - if entry.is_arg and len(entry.cf_assignments) > 1: + if entry.is_arg and len(entry.cf_assignments) > 1 and not entry.in_closure: if entry.xdecref_cleanup: code.put_var_xincref(entry) else: diff --git a/tests/run/closure_leak_1.pyx b/tests/run/closure_leak_1.pyx new file mode 100644 index 000000000..f33e034be --- /dev/null +++ b/tests/run/closure_leak_1.pyx @@ -0,0 +1,11 @@ +# mode: run +# tag: closure + +def reassign_args(x, *args): + """ + >>> reassign_args(1, [1,2,3,4]) + """ + a,args = args[0], args[1:] + b = False + if b: + c = x.map_coefficients(lambda c: c(*args)) |