From: Georg Brandl Date: Sun, 14 Apr 2013 09:45:16 +0000 (+0200) Subject: Fix refcount leak in the reference counting example section (!). X-Git-Tag: v2.7.5~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10bb21e4f964ee35004efbf75ea9ae5c5873af28;p=thirdparty%2FPython%2Fcpython.git Fix refcount leak in the reference counting example section (!). --- diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index c3a9ed633bd5..6414277c849f 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;