Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8a9304

Browse files
committed
Merged revisions 66693 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r66693 | benjamin.peterson | 2008-09-29 21:11:07 -0500 (Mon, 29 Sep 2008) | 4 lines Victor Stinner's patches to check the return result of PyLong_Ssize_t reviewed by Amaury ........
1 parent cb9a551 commit a8a9304

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Modules/_bytesio.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ bytesio_read(BytesIOObject *self, PyObject *args)
221221

222222
if (PyLong_Check(arg)) {
223223
size = PyLong_AsSsize_t(arg);
224+
if (size == -1 && PyErr_Occurred())
225+
return NULL;
224226
}
225227
else if (arg == Py_None) {
226228
/* Read until EOF is reached, by default. */
@@ -288,6 +290,8 @@ bytesio_readline(BytesIOObject *self, PyObject *args)
288290

289291
if (PyLong_Check(arg)) {
290292
size = PyLong_AsSsize_t(arg);
293+
if (size == -1 && PyErr_Occurred())
294+
return NULL;
291295
}
292296
else if (arg == Py_None) {
293297
/* No size limit, by default. */
@@ -332,6 +336,8 @@ bytesio_readlines(BytesIOObject *self, PyObject *args)
332336

333337
if (PyLong_Check(arg)) {
334338
maxsize = PyLong_AsSsize_t(arg);
339+
if (maxsize == -1 && PyErr_Occurred())
340+
return NULL;
335341
}
336342
else if (arg == Py_None) {
337343
/* No size limit, by default. */
@@ -415,6 +421,8 @@ bytesio_truncate(BytesIOObject *self, PyObject *args)
415421

416422
if (PyLong_Check(arg)) {
417423
size = PyLong_AsSsize_t(arg);
424+
if (size == -1 && PyErr_Occurred())
425+
return NULL;
418426
}
419427
else if (arg == Py_None) {
420428
/* Truncate to current position if no argument is passed. */

Modules/_struct.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,8 @@ s_pack_into(PyObject *self, PyObject *args)
17861786

17871787
/* Extract the offset from the first argument */
17881788
offset = PyLong_AsSsize_t(PyTuple_GET_ITEM(args, 1));
1789+
if (offset == -1 && PyErr_Occurred())
1790+
return NULL;
17891791

17901792
/* Support negative offsets. */
17911793
if (offset < 0)

0 commit comments

Comments
 (0)