Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 36dcaab

Browse files
ZackerySpytzserhiy-storchaka
authored andcommitted
Fix the error handling in bytesio_sizeof(). (pythonGH-10459)
bytesio_sizeof() must check if an error has occurred in _PySys_GetSizeOf().
1 parent bdbad71 commit 36dcaab

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎Modules/_io/bytesio.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,13 @@ bytesio_sizeof(bytesio *self, void *unused)
943943
Py_ssize_t res;
944944

945945
res = _PyObject_SIZE(Py_TYPE(self));
946-
if (self->buf && !SHARED_BUF(self))
947-
res += _PySys_GetSizeOf(self->buf);
946+
if (self->buf && !SHARED_BUF(self)) {
947+
Py_ssize_t s = _PySys_GetSizeOf(self->buf);
948+
if (s == -1) {
949+
return NULL;
950+
}
951+
res += s;
952+
}
948953
return PyLong_FromSsize_t(res);
949954
}
950955

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /