File: bug.c
Function: make_a_list_of_random_ints_badly
Error: ob_refcnt of '*item' is 1 too high
3 PyObject *
4 make_a_list_of_random_ints_badly(PyObject *self,
5                                  PyObject *args)
6 {
7     PyObject *list, *item;
8     long count, i;
9 
10     if (!PyArg_ParseTuple(args, "i", &count)) {
when PyArg_ParseTuple() succeeds
taking False path
11          return NULL;
12     }
13 
14     list = PyList_New(0);
when PyList_New() succeeds
15 
16     for (i = 0; i < count; i++) {
when considering range: 1 <= value <= 0x7fffffff
taking True path
when considering value == (int)1 from bug.c:10
taking False path
17         item = PyLong_FromLong(random());
when PyLong_FromLong() succeeds
PyLongObject allocated at:         item = PyLong_FromLong(random());
ob_refcnt is now refs: 1 + N where N >= 0
18         PyList_Append(list, item);
when PyList_Append() succeeds
ob_refcnt is now refs: 2 + N where N >= 0
'*item' is now referenced by 1 non-stack value(s): PyListObject.ob_item[0]
19     }
20 
21     return list;
22 }
ob_refcnt of '*item' is 1 too high
was expecting final ob_refcnt to be N + 1 (for some unknown N)
due to object being referenced by: PyListObject.ob_item[0]
but final ob_refcnt is N + 2
found 1 similar trace(s) to this

File: bug.c
Function: make_a_list_of_random_ints_badly
Error: calling PyList_Append with NULL as argument 1 (list) at bug.c:18
3 PyObject *
4 make_a_list_of_random_ints_badly(PyObject *self,
5                                  PyObject *args)
6 {
7     PyObject *list, *item;
8     long count, i;
9 
10     if (!PyArg_ParseTuple(args, "i", &count)) {
when PyArg_ParseTuple() succeeds
taking False path
11          return NULL;
12     }
13 
14     list = PyList_New(0);
when PyList_New() fails
15 
16     for (i = 0; i < count; i++) {
when considering range: 1 <= value <= 0x7fffffff
taking True path
17         item = PyLong_FromLong(random());
when PyLong_FromLong() succeeds
18         PyList_Append(list, item);
calling PyList_Append with NULL as argument 1 (list) at bug.c:18
PyList_Append() invokes Py_TYPE() on the pointer via the PyList_Check() macro, thus accessing (NULL)->ob_type
found 1 similar trace(s) to this
19     }
20 
21     return list;
22 }