File: python-ethtool/ethtool.c
Function: get_devices
Error: dereferencing NULL (str->ob_refcnt) at python-ethtool/ethtool.c:140
110 static PyObject *get_devices(PyObject *self __unused, PyObject *args __unused)
111 {
112 	char buffer[256];
113 	char *ret;;
114 	PyObject *list = PyList_New(0);
115 	FILE *fd = fopen(_PATH_PROCNET_DEV, "r");
when PyList_New() succeeds
116 
117 	if (fd == NULL) {
118 		PyErr_SetString(PyExc_OSError, strerror(errno));
when treating unknown struct FILE * from python-ethtool/ethtool.c:116 as non-NULL
taking False path
119 		return NULL;
120 	}
121 	/* skip over first two lines */
122 	ret = fgets(buffer, 256, fd); ret = fgets(buffer, 256, fd);
123 	while (!feof(fd)) {
124 		PyObject *str;
when considering value == (int)0 from python-ethtool/ethtool.c:124
taking True path
125 		char *name = buffer;
126 		char *end = buffer;
127 
128 		if (fgets(buffer, 256, fd) == NULL)
129 			break;
when treating unknown char * from python-ethtool/ethtool.c:129 as non-NULL
taking False path
130 		/* find colon */
131 		while (end && *end != ':')
132 			end++;
taking True path
when taking False path
133 		*end = 0; /* terminate where colon was */
134 		while (*name == ' ')
135 			name++; /* skip over leading whitespace if any */
taking False path
136 
137 		str = PyString_FromString(name);
138 		PyList_Append(list, str);
when PyString_FromString() fails
139 		Py_DECREF(str);
returning -1 from PyList_Append() due to NULL item
140 	}
dereferencing NULL (str->ob_refcnt) at python-ethtool/ethtool.c:140
141 	fclose(fd);
142 	return list;
143 }
144 

File: python-ethtool/ethtool.c
Function: get_devices
Error: ob_refcnt of '*list' is 1 too high
110 static PyObject *get_devices(PyObject *self __unused, PyObject *args __unused)
111 {
112 	char buffer[256];
113 	char *ret;;
114 	PyObject *list = PyList_New(0);
115 	FILE *fd = fopen(_PATH_PROCNET_DEV, "r");
when PyList_New() succeeds
PyListObject allocated at: 	PyObject *list = PyList_New(0);
ob_refcnt is now refs: 1 + N where N >= 0
116 
117 	if (fd == NULL) {
118 		PyErr_SetString(PyExc_OSError, strerror(errno));
when treating unknown struct FILE * from python-ethtool/ethtool.c:116 as NULL
taking True path
119 		return NULL;
when treating unknown int * from python-ethtool/ethtool.c:119 as non-NULL
calling PyErr_SetString()
120 	}
121 	/* skip over first two lines */
122 	ret = fgets(buffer, 256, fd); ret = fgets(buffer, 256, fd);
123 	while (!feof(fd)) {
124 		PyObject *str;
125 		char *name = buffer;
126 		char *end = buffer;
127 
128 		if (fgets(buffer, 256, fd) == NULL)
129 			break;
130 		/* find colon */
131 		while (end && *end != ':')
132 			end++;
133 		*end = 0; /* terminate where colon was */
134 		while (*name == ' ')
135 			name++; /* skip over leading whitespace if any */
136 
137 		str = PyString_FromString(name);
138 		PyList_Append(list, str);
139 		Py_DECREF(str);
140 	}
141 	fclose(fd);
142 	return list;
143 }
144 
ob_refcnt of '*list' 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: python-ethtool/ethtool.c
Function: get_devices
Error: calling PyList_Append with NULL as argument 1 (list) at python-ethtool/ethtool.c:139
110 static PyObject *get_devices(PyObject *self __unused, PyObject *args __unused)
111 {
112 	char buffer[256];
113 	char *ret;;
114 	PyObject *list = PyList_New(0);
115 	FILE *fd = fopen(_PATH_PROCNET_DEV, "r");
when PyList_New() fails
116 
117 	if (fd == NULL) {
118 		PyErr_SetString(PyExc_OSError, strerror(errno));
when treating unknown struct FILE * from python-ethtool/ethtool.c:116 as non-NULL
taking False path
119 		return NULL;
120 	}
121 	/* skip over first two lines */
122 	ret = fgets(buffer, 256, fd); ret = fgets(buffer, 256, fd);
123 	while (!feof(fd)) {
124 		PyObject *str;
when considering value == (int)0 from python-ethtool/ethtool.c:124
taking True path
125 		char *name = buffer;
126 		char *end = buffer;
127 
128 		if (fgets(buffer, 256, fd) == NULL)
129 			break;
when treating unknown char * from python-ethtool/ethtool.c:129 as non-NULL
taking False path
130 		/* find colon */
131 		while (end && *end != ':')
132 			end++;
taking True path
when taking False path
133 		*end = 0; /* terminate where colon was */
134 		while (*name == ' ')
135 			name++; /* skip over leading whitespace if any */
taking False path
136 
137 		str = PyString_FromString(name);
138 		PyList_Append(list, str);
when PyString_FromString() succeeds
139 		Py_DECREF(str);
calling PyList_Append with NULL as argument 1 (list) at python-ethtool/ethtool.c:139
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
140 	}
141 	fclose(fd);
142 	return list;
143 }
144