aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-04-09 00:25:17 +0000
committerGregory P. Smith <greg@mad-scientist.com>2008-04-09 00:25:17 +0000
commit79e42a0e0817b9c9fc23b333524427662b33986d (patch)
tree5e61bf69ea3291250f08e8616665d941345057d4 /Modules/zlibmodule.c
parent- Issue #2550: The approach used by client/server code for obtaining ports (diff)
downloadcpython-79e42a0e0817b9c9fc23b333524427662b33986d.tar.gz
cpython-79e42a0e0817b9c9fc23b333524427662b33986d.tar.bz2
cpython-79e42a0e0817b9c9fc23b333524427662b33986d.zip
Fix zlib crash from zlib.decompressobj().flush(val) when val was not positive.
It tried to allocate negative or zero memory. That fails.
Diffstat (limited to 'Modules/zlibmodule.c')
-rw-r--r--Modules/zlibmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index f59343f298a..4f78dbcb15d 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -774,6 +774,10 @@ PyZlib_unflush(compobject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|i:flush", &length))
return NULL;
+ if (length <= 0) {
+ PyErr_SetString(PyExc_ValueError, "length must be greater than zero");
+ return NULL;
+ }
if (!(retval = PyString_FromStringAndSize(NULL, length)))
return NULL;