miniupnpcmodule.c: check return of WSAStartup()

This commit is contained in:
Thomas Bernard 2018-10-31 16:34:00 +01:00
parent 33de3996d7
commit 6ae3445c2e
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 10 additions and 0 deletions

View File

@ -676,6 +676,16 @@ initminiupnpc(void)
/* initialize Winsock. */
WSADATA wsaData;
int nResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (nResult != 0)
{
/* error code could be WSASYSNOTREADY WSASYSNOTREADY
* WSASYSNOTREADY WSASYSNOTREADY WSASYSNOTREADY */
#if PY_MAJOR_VERSION >= 3
return 0;
#else
return;
#endif
}
UPnPType.tp_new = PyType_GenericNew;
#endif