1. Armin Rigo
  2. cpython-withatomic

Commits

Benjamin Peterson  committed 6a73134

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

reviewed by Amaury

  • Participants
  • Parent commits f4aeb11
  • Branches legacy-trunk

Comments (0)

Files changed (2)

File Modules/_bytesio.c

View file
  • Ignore whitespace
 
     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. */
 
     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. */
 
     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. */
 
     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. */

File Modules/_struct.c

View file
  • Ignore whitespace
 
 	/* 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)