summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-06-01 21:07:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-06-01 21:07:45 (GMT)
commit36dcaab7fde5d2e54cdeff5b705b5adcb27726dd (patch)
tree5dc6d17c0fc5aeb830943b4188f9b796fb9f8060
parentbdbad71b9def0b86433de12cecca022eee91bd9f (diff)
downloadcpython-36dcaab7fde5d2e54cdeff5b705b5adcb27726dd.zip
cpython-36dcaab7fde5d2e54cdeff5b705b5adcb27726dd.tar.gz
cpython-36dcaab7fde5d2e54cdeff5b705b5adcb27726dd.tar.bz2
Fix the error handling in bytesio_sizeof(). (GH-10459)
bytesio_sizeof() must check if an error has occurred in _PySys_GetSizeOf().
-rw-r--r--Modules/_io/bytesio.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index 32427e4..19e1ed8 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -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);
}