Skip to content

Commit abbe53e

Browse files
committed
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().
1 parent 019ed67 commit abbe53e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Modules/socketmodule.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,20 +3863,22 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
38633863
arglen = PyTuple_Size(args);
38643864
switch (arglen) {
38653865
case 2:
3866-
PyArg_ParseTuple(args, "y*O:sendto", &pbuf, &addro);
3866+
if (!PyArg_ParseTuple(args, "y*O:sendto", &pbuf, &addro)) {
3867+
return NULL;
3868+
}
38673869
break;
38683870
case 3:
3869-
PyArg_ParseTuple(args, "y*iO:sendto",
3870-
&pbuf, &flags, &addro);
3871+
if (!PyArg_ParseTuple(args, "y*iO:sendto",
3872+
&pbuf, &flags, &addro)) {
3873+
return NULL;
3874+
}
38713875
break;
38723876
default:
38733877
PyErr_Format(PyExc_TypeError,
38743878
"sendto() takes 2 or 3 arguments (%d given)",
38753879
arglen);
38763880
return NULL;
38773881
}
3878-
if (PyErr_Occurred())
3879-
return NULL;
38803882

38813883
if (!IS_SELECTABLE(s)) {
38823884
PyBuffer_Release(&pbuf);

0 commit comments

Comments
 (0)