summaryrefslogtreecommitdiff
path: root/Modules/zlibmodule.c
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2011-05-14 14:29:07 +0200
committerNadeem Vawda <nadeem.vawda@gmail.com>2011-05-14 14:29:07 +0200
commit0cc4fd9df7e2a6d6a47c20e66c5b22d590c6be51 (patch)
tree1f9553a5b486926d712b24f909bd55222d094724 /Modules/zlibmodule.c
parent9b323a521c8612093ff1d23b25c4d9809601e1d6 (diff)
downloadcpython-git-0cc4fd9df7e2a6d6a47c20e66c5b22d590c6be51.tar.gz
Issue #12050: zlib.decompressobj().decompress() now clears the unconsumed_tail
attribute when called without a max_length argument.
Diffstat (limited to 'Modules/zlibmodule.c')
-rw-r--r--Modules/zlibmodule.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index 183f01e91a..bd6d6e256b 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -535,17 +535,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 = PyString_FromStringAndSize((char *)self->zst.next_in,
self->zst.avail_in);
- if(!self->unconsumed_tail) {
- Py_DECREF(RetVal);
- RetVal = NULL;
- goto error;
- }
+ }
+ else if (PyString_GET_SIZE(self->unconsumed_tail) > 0) {
+ /* All of the compressed data was consumed. Clear unconsumed_tail. */
+ Py_DECREF(self->unconsumed_tail);
+ self->unconsumed_tail = PyString_FromStringAndSize("", 0);
+ }
+ if(!self->unconsumed_tail) {
+ Py_DECREF(RetVal);
+ RetVal = NULL;
+ goto error;
}
/* The end of the compressed data has been reached, so set the