Skip to content

Commit

Permalink
Address a minor Coverity warning re: unchecked PyArg_ParseTuple calls
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
gpshead committed Jan 18, 2017
1 parent aeaf294 commit 8128d5a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3863,20 +3863,22 @@ 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,
"sendto() takes 2 or 3 arguments (%d given)",
arglen);
return NULL;
}
if (PyErr_Occurred())
return NULL;

if (!IS_SELECTABLE(s)) {
PyBuffer_Release(&pbuf);
Expand Down

0 comments on commit 8128d5a

Please sign in to comment.