Re: [Python-Dev] [Python-checkins] cpython (merge 3.2 -> default): Closed reference leak of variable 'k' in function ste_new which wasn't decrefed
christian.heimes <python-checkins@python.org> wrote:
summary: Closed reference leak of variable 'k' in function ste_new which wasn't decrefed in error cases
files: Python/symtable.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Python/symtable.c b/Python/symtable.c --- a/Python/symtable.c +++ b/Python/symtable.c @@ -24,7 +24,7 @@ void *key, int lineno, int col_offset) { PySTEntryObject *ste = NULL; - PyObject *k; + PyObject *k = NULL;
k = PyLong_FromVoidPtr(key); if (k == NULL) @@ -79,6 +79,7 @@
return ste; fail: + Py_XDECREF(k); Py_XDECREF(ste);
I think 'k' is owned by the PySTEntryObject after it is assigned here: ste->ste_id = k; So ste_dealloc() will call Py_XDECREF(k) a second time. Stefan Krah
Am 12.09.2012 17:42, schrieb Stefan Krah:
I think 'k' is owned by the PySTEntryObject after it is assigned here:
ste->ste_id = k;
So ste_dealloc() will call Py_XDECREF(k) a second time.
You are right. I missed that ste steals the reference to k and does its own cleanup. I've fixed the issue and moved Py_DECREF(k) into ste == NULL block. http://hg.python.org/cpython/rev/2888356cdd4e http://hg.python.org/cpython/rev/99ab7006e466 Thanks!
participants (2)
-
Christian Heimes
-
Stefan Krah