Kaydet (Commit) 6de7d0c3 authored tarafından Fred Drake's avatar Fred Drake

When _PyString_Resize() reports failure, the variable referring to the

string we wanted to resize is set to NULL.  Don't Py_DECREF() those
variables!  (5 places)
üst 654387ef
...@@ -224,7 +224,6 @@ PyZlib_decompress(self, args) ...@@ -224,7 +224,6 @@ PyZlib_decompress(self, args)
PyErr_SetString(PyExc_MemoryError, PyErr_SetString(PyExc_MemoryError,
"Out of memory while decompressing data"); "Out of memory while decompressing data");
inflateEnd(&zst); inflateEnd(&zst);
Py_DECREF(result_str);
return NULL; return NULL;
} }
zst.next_out = (unsigned char *)PyString_AsString(result_str) + r_strlen; zst.next_out = (unsigned char *)PyString_AsString(result_str) + r_strlen;
...@@ -407,7 +406,6 @@ PyZlib_objcompress(self, args) ...@@ -407,7 +406,6 @@ PyZlib_objcompress(self, args)
if (_PyString_Resize(&RetVal, length << 1) == -1) { if (_PyString_Resize(&RetVal, length << 1) == -1) {
PyErr_SetString(PyExc_MemoryError, PyErr_SetString(PyExc_MemoryError,
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
Py_DECREF(RetVal);
return NULL; return NULL;
} }
self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
...@@ -466,7 +464,6 @@ PyZlib_objdecompress(self, args) ...@@ -466,7 +464,6 @@ PyZlib_objdecompress(self, args)
{ {
PyErr_SetString(PyExc_MemoryError, PyErr_SetString(PyExc_MemoryError,
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
Py_DECREF(RetVal);
return NULL; return NULL;
} }
self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
...@@ -521,7 +518,6 @@ PyZlib_flush(self, args) ...@@ -521,7 +518,6 @@ PyZlib_flush(self, args)
if (_PyString_Resize(&RetVal, length << 1) == -1) { if (_PyString_Resize(&RetVal, length << 1) == -1) {
PyErr_SetString(PyExc_MemoryError, PyErr_SetString(PyExc_MemoryError,
"Can't allocate memory to compress data"); "Can't allocate memory to compress data");
Py_DECREF(RetVal);
return NULL; return NULL;
} }
self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
...@@ -591,7 +587,6 @@ PyZlib_unflush(self, args) ...@@ -591,7 +587,6 @@ PyZlib_unflush(self, args)
{ {
PyErr_SetString(PyExc_MemoryError, PyErr_SetString(PyExc_MemoryError,
"Can't allocate memory to decompress data"); "Can't allocate memory to decompress data");
Py_DECREF(RetVal);
return NULL; return NULL;
} }
self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length; self->zst.next_out = (unsigned char *)PyString_AsString(RetVal) + length;
......
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