]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix refcount leak in the reference counting example section (!).
authorGeorg Brandl <georg@python.org>
Sun, 14 Apr 2013 09:45:16 +0000 (11:45 +0200)
committerGeorg Brandl <georg@python.org>
Sun, 14 Apr 2013 09:45:16 +0000 (11:45 +0200)
Doc/c-api/intro.rst

index c3a9ed633bd5846403b5718e2e0ad626e3daf641..6414277c849f472e84647bd1d02f10cbe1ee7bfa 100644 (file)
@@ -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;