Issue #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail

attribute when called without a max_length argument.
This commit is contained in:
Nadeem Vawda 2011-05-14 14:05:20 +02:00
parent eda199030b
commit 7619e88adb
3 changed files with 24 additions and 7 deletions

View file

@ -560,17 +560,22 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
Py_END_ALLOW_THREADS
}
/* Not all of the compressed data could be accommodated in the output buffer
of specified size. Return the unconsumed tail in an attribute.*/
if(max_length) {
/* Not all of the compressed data could be accommodated in a buffer of
the specified size. Return the unconsumed tail in an attribute. */
Py_DECREF(self->unconsumed_tail);
self->unconsumed_tail = PyBytes_FromStringAndSize((char *)self->zst.next_in,
self->zst.avail_in);
if(!self->unconsumed_tail) {
Py_DECREF(RetVal);
RetVal = NULL;
goto error;
}
}
else if (PyBytes_GET_SIZE(self->unconsumed_tail) > 0) {
/* All of the compressed data was consumed. Clear unconsumed_tail. */
Py_DECREF(self->unconsumed_tail);
self->unconsumed_tail = PyBytes_FromStringAndSize("", 0);
}
if (self->unconsumed_tail == NULL) {
Py_DECREF(RetVal);
RetVal = NULL;
goto error;
}
/* The end of the compressed data has been reached, so set the