File: bitarray/_bitarray.c
Function: newbitarrayobject
Error: returning (PyObject*)NULL without setting an exception
142 static PyObject *
143 newbitarrayobject(PyTypeObject *type, idx_t nbits, int endian)
144 {
145     bitarrayobject *obj;
146     Py_ssize_t nbytes;
147 
148     if (check_overflow(nbits) < 0)
when considering range: -0x80000000 <= value <= -1
taking True path
149         return NULL;
150 
151     obj = (bitarrayobject *) type->tp_alloc(type, 0);
152     if (obj == NULL)
153         return NULL;
154 
155     nbytes = (Py_ssize_t) BYTES(nbits);
156     Py_SIZE(obj) = nbytes;
157     obj->nbits = nbits;
158     obj->endian = endian;
159     if (nbytes == 0) {
160         obj->ob_item = NULL;
161     }
162     else {
163         obj->ob_item = PyMem_Malloc((size_t) nbytes);
164         if (obj->ob_item == NULL) {
165             PyObject_Del(obj);
166             PyErr_NoMemory();
167             return NULL;
168         }
169     }
170     obj->allocated = nbytes;
171     obj->weakreflist = NULL;
172     return (PyObject *) obj;
173 }
returning (PyObject*)NULL without setting an exception

File: bitarray/_bitarray.c
Function: newbitarrayobject
Error: ob_refcnt of '*obj' is 1 too high
142 static PyObject *
143 newbitarrayobject(PyTypeObject *type, idx_t nbits, int endian)
144 {
145     bitarrayobject *obj;
146     Py_ssize_t nbytes;
147 
148     if (check_overflow(nbits) < 0)
when considering range: 0 <= value <= 0x7fffffff
taking False path
149         return NULL;
150 
151     obj = (bitarrayobject *) type->tp_alloc(type, 0);
when call succeeds
new ref from call through function pointer allocated at:     obj = (bitarrayobject *) type->tp_alloc(type, 0);
ob_refcnt is now refs: 1 + N where N >= 0
152     if (obj == NULL)
taking False path
153         return NULL;
154 
155     nbytes = (Py_ssize_t) BYTES(nbits);
when considering range: -0x8000000000000000 <= value <= -1
taking True path
156     Py_SIZE(obj) = nbytes;
157     obj->nbits = nbits;
158     obj->endian = endian;
159     if (nbytes == 0) {
when considering range: -0xfffffffffffffff <= value <= -1
taking False path
160         obj->ob_item = NULL;
161     }
162     else {
163         obj->ob_item = PyMem_Malloc((size_t) nbytes);
when PyMem_Malloc() fails
164         if (obj->ob_item == NULL) {
taking True path
165             PyObject_Del(obj);
166             PyErr_NoMemory();
PyErr_NoMemory() returns NULL, raising MemoryError
167             return NULL;
168         }
169     }
170     obj->allocated = nbytes;
171     obj->weakreflist = NULL;
172     return (PyObject *) obj;
173 }
ob_refcnt of '*obj' is 1 too high
was expecting final ob_refcnt to be N + 0 (for some unknown N)
but final ob_refcnt is N + 1
found 1 similar trace(s) to this