From 6ae3445c2eb0255034976edbb4d16b6962936cfb Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Wed, 31 Oct 2018 16:34:00 +0100 Subject: [PATCH] miniupnpcmodule.c: check return of WSAStartup() --- miniupnpc/miniupnpcmodule.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/miniupnpc/miniupnpcmodule.c b/miniupnpc/miniupnpcmodule.c index 8657a0e..14dde5a 100644 --- a/miniupnpc/miniupnpcmodule.c +++ b/miniupnpc/miniupnpcmodule.c @@ -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