summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2011-05-14 12:19:56 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2011-05-14 12:19:56 (GMT)
commit9c405c470b4c886d96d3db9cea62d46f11ae4973 (patch)
treed77f390941a5f5208bdedf6cbf8a75af31be989a /Modules
parent63db5b65105adbb3038134f9a19d619fc5e8d638 (diff)
parent5eef502de091c76d98786673dfece816572662f7 (diff)
downloadcpython-9c405c470b4c886d96d3db9cea62d46f11ae4973.zip
cpython-9c405c470b4c886d96d3db9cea62d46f11ae4973.tar.gz
cpython-9c405c470b4c886d96d3db9cea62d46f11ae4973.tar.bz2
Merge: #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail
attribute when called without a max_length argument.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/zlibmodule.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index 206ef0c..969db4a 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -574,17 +574,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