diff --git a/libretroshare/src/upnp/UPnPBase.cpp b/libretroshare/src/upnp/UPnPBase.cpp index b737bfdcd..d3d09afec 100644 --- a/libretroshare/src/upnp/UPnPBase.cpp +++ b/libretroshare/src/upnp/UPnPBase.cpp @@ -1304,7 +1304,10 @@ int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /* // Somehow, this is unreliable. UPNP_DISCOVERY_ADVERTISEMENT_ALIVE events // happen with a wrong cookie and... boom! // CUPnPControlPoint *upnpCP = static_cast(Cookie); - CUPnPControlPoint *upnpCP = CUPnPControlPoint::s_CtrlPoint; + CUPnPControlPoint *upnpCP = CUPnPControlPoint::s_CtrlPoint; + + if(upnpCP == NULL) + return 0 ; //fprintf(stderr, "Callback: %d, Cookie: %p\n", EventType, Cookie); switch (EventType) { diff --git a/libretroshare/src/upnp/upnphandler_linux.cc b/libretroshare/src/upnp/upnphandler_linux.cc index 4cec21bac..e95fe839b 100644 --- a/libretroshare/src/upnp/upnphandler_linux.cc +++ b/libretroshare/src/upnp/upnphandler_linux.cc @@ -232,7 +232,8 @@ bool upnphandler::shutdown_upnp() //destroy the upnp object cUPnPControlPoint->~CUPnPControlPoint(); - } else { + cUPnPControlPoint=NULL ; + } else { #ifdef UPNP_DEBUG std::cerr << "upnphandler::shutdown_upnp() : avoid upnp connection for shutdonws because probably a net flag went down." << std::endl; #endif