mirror of
https://github.com/python/cpython.git
synced 2026-01-04 14:32:21 +00:00
Fix the error handling in bytesio_sizeof(). (GH-10459)
bytesio_sizeof() must check if an error has occurred in _PySys_GetSizeOf().
This commit is contained in:
parent
bdbad71b9d
commit
36dcaab7fd
1 changed files with 7 additions and 2 deletions
|
|
@ -943,8 +943,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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue