{
PyErr_SetString(PyExc_MemoryError,
"Can't allocate memory to compress data");
- free(output);
-
return NULL;
}
zst.avail_in = length;
zst.avail_out = r_strlen;
- if (!(result_str = PyString_FromStringAndSize(NULL, r_strlen))) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to decompress data");
+ if (!(result_str = PyString_FromStringAndSize(NULL, r_strlen)))
return NULL;
- }
/* Past the point of no return. From here on out, we need to make sure
we clean up mallocs & INCREFs. */
case(Z_OK):
/* need more memory */
if (_PyString_Resize(&result_str, r_strlen << 1) == -1) {
- PyErr_SetString(PyExc_MemoryError,
- "Out of memory while decompressing data");
inflateEnd(&zst);
result_str = NULL;
return_error = 1;
if (PyString_AsStringAndSize(inputString, (char**)&input, &inplen) == -1)
return NULL;
- if (!(RetVal = PyString_FromStringAndSize(NULL, length))) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to compress data");
+ if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
return NULL;
- }
ENTER_ZLIB
so extend the output buffer and try again */
while (err == Z_OK && self->zst.avail_out == 0) {
if (_PyString_Resize(&RetVal, length << 1) == -1) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to compress data");
return_error = 1;
break;
}
/* limit amount of data allocated to max_length */
if (max_length && length > max_length)
length = max_length;
- if (!(RetVal = PyString_FromStringAndSize(NULL, length))) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to compress data");
+ if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
return NULL;
- }
ENTER_ZLIB
return_error = 0;
length = max_length;
if (_PyString_Resize(&RetVal, length) == -1) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to compress data");
return_error = 1;
break;
}
self->unused_data = PyString_FromStringAndSize(
(char *)self->zst.next_in, self->zst.avail_in);
if (self->unused_data == NULL) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to unused_data");
Py_DECREF(RetVal);
return_error = 1;
}
return PyString_FromStringAndSize(NULL, 0);
}
- if (!(RetVal = PyString_FromStringAndSize(NULL, length))) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to compress data");
+ if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
return NULL;
- }
ENTER_ZLIB
so extend the output buffer and try again */
while (err == Z_OK && self->zst.avail_out == 0) {
if (_PyString_Resize(&RetVal, length << 1) == -1) {
- PyErr_SetString(PyExc_MemoryError,
- "Can't allocate memory to compress data");
return_error = 1;
break;
}