File: | psutil/_psutil_linux.c |
Function: | get_disk_partitions |
Error: | ob_refcnt of '*py_retlist' is 1 too high |
101 static PyObject*
102 get_disk_partitions(PyObject* self, PyObject* args)
103 {
104 FILE *file;
105 struct mntent *entry;
106 PyObject* py_retlist = PyList_New(0);
when PyList_New() succeeds
PyListObject allocated at: PyObject* py_retlist = PyList_New(0);
ob_refcnt is now refs: 1 + N where N >= 0
107 PyObject* py_tuple;
108
109 // MOUNTED constant comes from mntent.h and it's == '/etc/mtab'
110 Py_BEGIN_ALLOW_THREADS
releasing the GIL by calling PyEval_SaveThread()
111 file = setmntent(MOUNTED, "r");
112 Py_END_ALLOW_THREADS
reacquiring the GIL by calling PyEval_RestoreThread()
113 if ((file == 0) || (file == NULL)) {
when treating unknown struct FILE * from psutil/_psutil_linux.c:111 as NULL
taking True path
114 return PyErr_SetFromErrno(PyExc_OSError);
PyErr_SetFromErrno()
115 }
116
117 while ((entry = getmntent(file))) {
118 if (entry == NULL) {
119 endmntent(file);
120 return PyErr_Format(PyExc_RuntimeError, "getmntent() failed");
121 }
122 py_tuple = Py_BuildValue("(sss)", entry->mnt_fsname, // device
123 entry->mnt_dir, // mount point
124 entry->mnt_type); // fs type
125 PyList_Append(py_retlist, py_tuple);
126 Py_XDECREF(py_tuple);
127 }
128
129 endmntent(file);
130 return py_retlist;
131 }
ob_refcnt of '*py_retlist' is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1
File: | psutil/_psutil_linux.c |
Function: | get_disk_partitions |
Error: | calling PyList_Append with NULL as argument 1 (py_retlist) at psutil/_psutil_linux.c:125 |
101 static PyObject*
102 get_disk_partitions(PyObject* self, PyObject* args)
103 {
104 FILE *file;
105 struct mntent *entry;
106 PyObject* py_retlist = PyList_New(0);
when PyList_New() fails
107 PyObject* py_tuple;
108
109 // MOUNTED constant comes from mntent.h and it's == '/etc/mtab'
110 Py_BEGIN_ALLOW_THREADS
releasing the GIL by calling PyEval_SaveThread()
111 file = setmntent(MOUNTED, "r");
112 Py_END_ALLOW_THREADS
reacquiring the GIL by calling PyEval_RestoreThread()
113 if ((file == 0) || (file == NULL)) {
when treating unknown struct FILE * from psutil/_psutil_linux.c:111 as non-NULL
taking False path
114 return PyErr_SetFromErrno(PyExc_OSError);
115 }
116
117 while ((entry = getmntent(file))) {
when treating unknown struct mntent * from psutil/_psutil_linux.c:117 as non-NULL
taking True path
118 if (entry == NULL) {
taking False path
119 endmntent(file);
120 return PyErr_Format(PyExc_RuntimeError, "getmntent() failed");
121 }
122 py_tuple = Py_BuildValue("(sss)", entry->mnt_fsname, // device
when Py_BuildValue() succeeds
123 entry->mnt_dir, // mount point
124 entry->mnt_type); // fs type
125 PyList_Append(py_retlist, py_tuple);
calling PyList_Append with NULL as argument 1 (py_retlist) at psutil/_psutil_linux.c:125
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
126 Py_XDECREF(py_tuple);
127 }
128
129 endmntent(file);
130 return py_retlist;
131 }