Kaydet (Commit) f3478d9d authored tarafından Andrew M. Kuchling's avatar Andrew M. Kuchling

[Bug #1083110] calling .flush() on decompress objects causes a segfault due to…

[Bug #1083110] calling .flush() on decompress objects causes a segfault due to an uninitialized pointer: fixes the problem and adds a test case
üst b0757b8a
...@@ -65,6 +65,11 @@ Extension modules ...@@ -65,6 +65,11 @@ Extension modules
- Patch #945642: Fix non-blocking SSL sockets, which blocked on reads/writes. - Patch #945642: Fix non-blocking SSL sockets, which blocked on reads/writes.
- Bug #1083110: ``zlib.decompress.flush()`` would segfault if called
immediately after creating the object, without any intervening
``.decompress()`` calls.
Library Library
------- -------
......
...@@ -301,6 +301,8 @@ PyZlib_compressobj(PyObject *selfptr, PyObject *args) ...@@ -301,6 +301,8 @@ PyZlib_compressobj(PyObject *selfptr, PyObject *args)
return(NULL); return(NULL);
self->zst.zalloc = (alloc_func)NULL; self->zst.zalloc = (alloc_func)NULL;
self->zst.zfree = (free_func)Z_NULL; self->zst.zfree = (free_func)Z_NULL;
self->zst.next_in = NULL;
self->zst.avail_in = 0;
err = deflateInit2(&self->zst, level, method, wbits, memLevel, strategy); err = deflateInit2(&self->zst, level, method, wbits, memLevel, strategy);
switch(err) { switch(err) {
case (Z_OK): case (Z_OK):
...@@ -335,6 +337,8 @@ PyZlib_decompressobj(PyObject *selfptr, PyObject *args) ...@@ -335,6 +337,8 @@ PyZlib_decompressobj(PyObject *selfptr, PyObject *args)
return(NULL); return(NULL);
self->zst.zalloc = (alloc_func)NULL; self->zst.zalloc = (alloc_func)NULL;
self->zst.zfree = (free_func)Z_NULL; self->zst.zfree = (free_func)Z_NULL;
self->zst.next_in = NULL;
self->zst.avail_in = 0;
err = inflateInit2(&self->zst, wbits); err = inflateInit2(&self->zst, wbits);
switch(err) { switch(err) {
case (Z_OK): case (Z_OK):
...@@ -516,7 +520,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args) ...@@ -516,7 +520,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
} }
/* Not all of the compressed data could be accomodated in the output buffer /* Not all of the compressed data could be accommodated in the output buffer
of specified size. Return the unconsumed tail in an attribute.*/ of specified size. Return the unconsumed tail in an attribute.*/
if(max_length) { if(max_length) {
Py_DECREF(self->unconsumed_tail); Py_DECREF(self->unconsumed_tail);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment