diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-09-30 02:11:07 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-09-30 02:11:07 (GMT) |
commit | 02252480336fbbf8507d51ccc88431fa59ecd07f (patch) | |
tree | c52148d32f770799251c8fdffdf534f8cacaef3b /Modules/_bytesio.c | |
parent | 8d77d448a53ed9d0607f1ad226056eb8ee8a48f8 (diff) | |
download | cpython-02252480336fbbf8507d51ccc88431fa59ecd07f.zip cpython-02252480336fbbf8507d51ccc88431fa59ecd07f.tar.gz cpython-02252480336fbbf8507d51ccc88431fa59ecd07f.tar.bz2 |
Victor Stinner's patches to check the return result of PyLong_Ssize_t
reviewed by Amaury
Diffstat (limited to 'Modules/_bytesio.c')
-rw-r--r-- | Modules/_bytesio.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_bytesio.c b/Modules/_bytesio.c index 8c5bb82..c5c14b3 100644 --- a/Modules/_bytesio.c +++ b/Modules/_bytesio.c @@ -221,6 +221,8 @@ bytesio_read(BytesIOObject *self, PyObject *args) if (PyInt_Check(arg)) { size = PyInt_AsSsize_t(arg); + if (size == -1 && PyErr_Occurred()) + return NULL; } else if (arg == Py_None) { /* Read until EOF is reached, by default. */ @@ -288,6 +290,8 @@ bytesio_readline(BytesIOObject *self, PyObject *args) if (PyInt_Check(arg)) { size = PyInt_AsSsize_t(arg); + if (size == -1 && PyErr_Occurred()) + return NULL; } else if (arg == Py_None) { /* No size limit, by default. */ @@ -332,6 +336,8 @@ bytesio_readlines(BytesIOObject *self, PyObject *args) if (PyInt_Check(arg)) { maxsize = PyInt_AsSsize_t(arg); + if (maxsize == -1 && PyErr_Occurred()) + return NULL; } else if (arg == Py_None) { /* No size limit, by default. */ @@ -415,6 +421,8 @@ bytesio_truncate(BytesIOObject *self, PyObject *args) if (PyInt_Check(arg)) { size = PyInt_AsSsize_t(arg); + if (size == -1 && PyErr_Occurred()) + return NULL; } else if (arg == Py_None) { /* Truncate to current position if no argument is passed. */ |