#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
- if (!self->lock)
+ if (!self->lock) {
+ PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
goto error;
+ }
#endif
if (mode_char == 'r')
return 0;
error:
- Py_DECREF(self->file);
+ Py_CLEAR(self->file);
#ifdef WITH_THREAD
- if (self->lock)
+ if (self->lock) {
PyThread_free_lock(self->lock);
+ self->lock = NULL;
+ }
#endif
return -1;
}
#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
- if (!self->lock)
+ if (!self->lock) {
+ PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
goto error;
+ }
#endif
memset(&self->bzs, 0, sizeof(bz_stream));
return 0;
error:
#ifdef WITH_THREAD
- if (self->lock)
+ if (self->lock) {
PyThread_free_lock(self->lock);
+ self->lock = NULL;
+ }
#endif
return -1;
}
#ifdef WITH_THREAD
self->lock = PyThread_allocate_lock();
- if (!self->lock)
+ if (!self->lock) {
+ PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
goto error;
+ }
#endif
self->unused_data = PyString_FromString("");
error:
#ifdef WITH_THREAD
- if (self->lock)
+ if (self->lock) {
PyThread_free_lock(self->lock);
+ self->lock = NULL;
+ }
#endif
- Py_XDECREF(self->unused_data);
+ Py_CLEAR(self->unused_data);
return -1;
}
for (i = self->length, p = self->data + clearto;
--i >= clearto;
p++) {
- Py_DECREF(*p);
+ Py_CLEAR(*p);
}
self->length = clearto;
{
int bigger;
size_t nbytes;
+ PyObject **tmp;
bigger = self->size << 1;
if (bigger <= 0) /* was 0, or new value overflows */
nbytes = (size_t)bigger * sizeof(PyObject *);
if (nbytes / sizeof(PyObject *) != (size_t)bigger)
goto nomemory;
- self->data = realloc(self->data, nbytes);
- if (self->data == NULL)
+ tmp = realloc(self->data, nbytes);
+ if (tmp == NULL)
goto nomemory;
+ self->data = tmp;
self->size = bigger;
return 0;
nomemory:
- self->size = 0;
PyErr_NoMemory();
return -1;
}
int list_len;
slice=Pdata_popList(self->stack, x);
+ if (!slice) return -1;
list_len = PyList_GET_SIZE(list);
i=PyList_SetSlice(list, list_len, list_len, slice);
Py_DECREF(slice);
if (!( self->memo = PyDict_New()))
goto err;
+ if (!self->stack)
+ goto err;
+
Py_INCREF(f);
self->file = f;