]> granicus.if.org Git - python/commitdiff
Victor Stinner's patches to check the return result of PyLong_Ssize_t
authorBenjamin Peterson <benjamin@python.org>
Tue, 30 Sep 2008 02:11:07 +0000 (02:11 +0000)
committerBenjamin Peterson <benjamin@python.org>
Tue, 30 Sep 2008 02:11:07 +0000 (02:11 +0000)
reviewed by Amaury

Modules/_bytesio.c
Modules/_struct.c

index 8c5bb82de326bf3c3b00876ca715c236648e2b12..c5c14b30617135d5cdd71fe7c1856f753fef168e 100644 (file)
@@ -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. */
index 078c3a53a852595f6546a4b444934185d4498df5..30feaa6fb1f9b4d8f929d7b31b28e07a64865cae 100644 (file)
@@ -1755,6 +1755,8 @@ s_pack_into(PyObject *self, PyObject *args)
 
        /* Extract the offset from the first argument */
        offset = PyInt_AsSsize_t(PyTuple_GET_ITEM(args, 1));
+       if (offset == -1 && PyErr_Occurred())
+               return NULL;
 
        /* Support negative offsets. */
        if (offset < 0)