[Python-checkins] r66693 - in python/trunk/Modules: _bytesio.c _struct.c

benjamin.peterson python-checkins at python.org
Tue Sep 30 04:11:07 CEST 2008


Author: benjamin.peterson
Date: Tue Sep 30 04:11:07 2008
New Revision: 66693

Log:
Victor Stinner's patches to check the return result of PyLong_Ssize_t

reviewed by Amaury


Modified:
   python/trunk/Modules/_bytesio.c
   python/trunk/Modules/_struct.c

Modified: python/trunk/Modules/_bytesio.c
==============================================================================
--- python/trunk/Modules/_bytesio.c	(original)
+++ python/trunk/Modules/_bytesio.c	Tue Sep 30 04:11:07 2008
@@ -221,6 +221,8 @@
 
     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 @@
 
     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 @@
 
     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 @@
 
     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. */

Modified: python/trunk/Modules/_struct.c
==============================================================================
--- python/trunk/Modules/_struct.c	(original)
+++ python/trunk/Modules/_struct.c	Tue Sep 30 04:11:07 2008
@@ -1755,6 +1755,8 @@
 
 	/* 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)


More information about the Python-checkins mailing list