diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-09 00:35:22 +0200 | 
|---|---|---|
| committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-09 00:35:22 +0200 | 
| commit | 79799266165b5d8d4e8b9b007d81ba3b00197ca9 (patch) | |
| tree | a79e1d91c4ec128ec35be099de28e7d5817fce52 /Modules/zlibmodule.c | |
| parent | e0af3a802a67d3467b18510869ee1cf9d233fe8e (diff) | |
| download | cpython-git-79799266165b5d8d4e8b9b007d81ba3b00197ca9.tar.gz | |
Issue #18408: Fix usage of _PyBytes_Resize()
_PyBytes_Resize(&v, new_size) sets v to NULL on error, so v cannot be used
anymore. Replace "Py_DECREF(v); v = NULL;" with "Py_CLEAR(v);".
Diffstat (limited to 'Modules/zlibmodule.c')
| -rw-r--r-- | Modules/zlibmodule.c | 24 | 
1 files changed, 8 insertions, 16 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index da0d3db5c6..169903e7ea 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -549,8 +549,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)         so extend the output buffer and try again */      while (err == Z_OK && self->zst.avail_out == 0) {          if (_PyBytes_Resize(&RetVal, length << 1) < 0) { -            Py_DECREF(RetVal); -            RetVal = NULL; +            Py_CLEAR(RetVal);              goto error;          }          self->zst.next_out = @@ -574,8 +573,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)          goto error;      }      if (_PyBytes_Resize(&RetVal, self->zst.total_out - start_total_out) < 0) { -        Py_DECREF(RetVal); -        RetVal = NULL; +        Py_CLEAR(RetVal);      }   error: @@ -722,8 +720,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)              length = max_length;          if (_PyBytes_Resize(&RetVal, length) < 0) { -            Py_DECREF(RetVal); -            RetVal = NULL; +            Py_CLEAR(RetVal);              goto error;          }          self->zst.next_out = @@ -757,8 +754,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)      }      if (_PyBytes_Resize(&RetVal, self->zst.total_out - start_total_out) < 0) { -        Py_DECREF(RetVal); -        RetVal = NULL; +        Py_CLEAR(RetVal);      }   error: @@ -811,8 +807,7 @@ PyZlib_flush(compobject *self, PyObject *args)         so extend the output buffer and try again */      while (err == Z_OK && self->zst.avail_out == 0) {          if (_PyBytes_Resize(&RetVal, length << 1) < 0) { -            Py_DECREF(RetVal); -            RetVal = NULL; +            Py_CLEAR(RetVal);              goto error;          }          self->zst.next_out = @@ -851,8 +846,7 @@ PyZlib_flush(compobject *self, PyObject *args)      }      if (_PyBytes_Resize(&RetVal, self->zst.total_out - start_total_out) < 0) { -        Py_DECREF(RetVal); -        RetVal = NULL; +        Py_CLEAR(RetVal);      }   error: @@ -1012,8 +1006,7 @@ PyZlib_unflush(compobject *self, PyObject *args)         so extend the output buffer and try again */      while ((err == Z_OK || err == Z_BUF_ERROR) && self->zst.avail_out == 0) {          if (_PyBytes_Resize(&retval, length << 1) < 0) { -            Py_DECREF(retval); -            retval = NULL; +            Py_CLEAR(retval);              goto error;          }          self->zst.next_out = (Byte *)PyBytes_AS_STRING(retval) + length; @@ -1045,8 +1038,7 @@ PyZlib_unflush(compobject *self, PyObject *args)      }      if (_PyBytes_Resize(&retval, self->zst.total_out - start_total_out) < 0) { -        Py_DECREF(retval); -        retval = NULL; +        Py_CLEAR(retval);      }  error:  | 
