Skip to content

Commit

Permalink
Fix the error handling in bytesio_sizeof(). (GH-10459)
Browse files Browse the repository at this point in the history
bytesio_sizeof() must check if an error has occurred in _PySys_GetSizeOf().
(cherry picked from commit 36dcaab)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
  • Loading branch information
miss-islington and ZackerySpytz committed Jun 1, 2019
1 parent fc914dd commit fefdc00
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Modules/_io/bytesio.c
Expand Up @@ -942,8 +942,13 @@ bytesio_sizeof(bytesio *self, void *unused)
Py_ssize_t res;

res = _PyObject_SIZE(Py_TYPE(self));
if (self->buf && !SHARED_BUF(self))
res += _PySys_GetSizeOf(self->buf);
if (self->buf && !SHARED_BUF(self)) {
Py_ssize_t s = _PySys_GetSizeOf(self->buf);
if (s == -1) {
return NULL;
}
res += s;
}
return PyLong_FromSsize_t(res);
}

Expand Down

0 comments on commit fefdc00

Please sign in to comment.