File: tests/cpychecker/refcounts/missing_decref/input.c
Function: missing_decref
Error: ob_refcnt of PyListObject is 1 too high
22 PyObject *
23 missing_decref(PyObject *self, PyObject *args)
24 {
25     PyObject *list;
26     PyObject *item;
27     list = PyList_New(1);
PyList_New() succeeds
PyListObject allocated at:     list = PyList_New(1);
28     if (!list)
taking False path
29         return NULL;
30     item = PyLong_FromLong(42);
PyLong_FromLong() fails
31     /* This error handling is incorrect: it's missing an
32        invocation of Py_DECREF(list): */
33     if (!item)
taking True path
34         return NULL;
35     /* This steals a reference to item; item is not leaked when we get here: */
36     PyList_SetItem(list, 0, item);
37     return list;
38 }
ob_refcnt of PyListObject is 1 too high