diff options
author | Georg Brandl <georg@python.org> | 2013-04-14 09:45:16 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-04-14 09:45:16 (GMT) |
commit | 10bb21e4f964ee35004efbf75ea9ae5c5873af28 (patch) | |
tree | 1f836f40ea4e523a475c0931c2b1ca5dcc38bff5 /Doc/c-api | |
parent | ba58cbe7541deb963c555af59e433f8046391a54 (diff) | |
download | cpython-10bb21e4f964ee35004efbf75ea9ae5c5873af28.zip cpython-10bb21e4f964ee35004efbf75ea9ae5c5873af28.tar.gz cpython-10bb21e4f964ee35004efbf75ea9ae5c5873af28.tar.bz2 |
Fix refcount leak in the reference counting example section (!).
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/intro.rst | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index c3a9ed6..6414277 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -255,8 +255,10 @@ sets all items of a list (actually, any mutable sequence) to a given item:: PyObject *index = PyInt_FromLong(i); if (!index) return -1; - if (PyObject_SetItem(target, index, item) < 0) + if (PyObject_SetItem(target, index, item) < 0) { + Py_DECREF(index); return -1; + } Py_DECREF(index); } return 0; |