[Python-checkins] cpython: Address a minor Coverity warning re: unchecked PyArg_ParseTuple calls

gregory.p.smith python-checkins at python.org
Tue Jan 17 19:55:15 EST 2017


https://hg.python.org/cpython/rev/173bc62b4438
changeset:   106204:173bc62b4438
user:        Gregory P. Smith <greg at krypto.org>
date:        Tue Jan 17 16:54:56 2017 -0800
summary:
  Address a minor Coverity warning re: unchecked PyArg_ParseTuple calls
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().

files:
  Modules/socketmodule.c |  12 +++++++-----
  1 files changed, 7 insertions(+), 5 deletions(-)


diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -3863,11 +3863,15 @@
     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 @@
                          arglen);
             return NULL;
     }
-    if (PyErr_Occurred())
-        return NULL;
 
     if (!IS_SELECTABLE(s)) {
         PyBuffer_Release(&pbuf);

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list