diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c index da5e869..7b1c317 100644 --- a/miniupnpc/minissdpc.c +++ b/miniupnpc/minissdpc.c @@ -685,10 +685,10 @@ ssdpDiscoverDevices(const char * const deviceTypes[], (linklocal ? "[" UPNP_MCAST_LL_ADDR "]" : "[" UPNP_MCAST_SL_ADDR "]") : UPNP_MCAST_ADDR, deviceTypes[deviceIndex], mx); - if ((unsigned int)n >= sizeof(bufr)) - { - closesocket(sudp); - return NULL; + if ((unsigned int)n >= sizeof(bufr)) { + if(error) + *error = MINISSDPC_MEMORY_ERROR; + goto error; } #ifdef DEBUG /*printf("Sending %s", bufr);*/