]> granicus.if.org Git - python/commitdiff
Address a minor Coverity warning re: unchecked PyArg_ParseTuple calls
authorGregory P. Smith <greg@krypto.org>
Wed, 18 Jan 2017 00:54:56 +0000 (16:54 -0800)
committerGregory P. Smith <greg@krypto.org>
Wed, 18 Jan 2017 00:54:56 +0000 (16:54 -0800)
in socket.sendto().  A PyErr_Occurred() check was happening later, but
it is better to just use the return value and not call PyErr_Occurred().

Modules/socketmodule.c

index d5506a63365d43ab856cc6a4fa04fc4bb5a5a617..274769d6b01bc56c29b99f772fbc9740d3477cc3 100644 (file)
@@ -3863,11 +3863,15 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
     arglen = PyTuple_Size(args);
     switch (arglen) {
         case 2:
-            PyArg_ParseTuple(args, "y*O:sendto", &pbuf, &addro);
+            if (!PyArg_ParseTuple(args, "y*O:sendto", &pbuf, &addro)) {
+                return NULL;
+            }
             break;
         case 3:
-            PyArg_ParseTuple(args, "y*iO:sendto",
-                             &pbuf, &flags, &addro);
+            if (!PyArg_ParseTuple(args, "y*iO:sendto",
+                                  &pbuf, &flags, &addro)) {
+                return NULL;
+            }
             break;
         default:
             PyErr_Format(PyExc_TypeError,
@@ -3875,8 +3879,6 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
                          arglen);
             return NULL;
     }
-    if (PyErr_Occurred())
-        return NULL;
 
     if (!IS_SELECTABLE(s)) {
         PyBuffer_Release(&pbuf);