From 973800b52f13e993110e351ec414eed54147118d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 15 Apr 2011 00:37:50 +0200 Subject: [PATCH 1/2] Exit when no UPnP router found and fUseUPnP gets set to 0. --- net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net.cpp b/net.cpp index 833aafc0a1..f3857baf61 100644 --- a/net.cpp +++ b/net.cpp @@ -939,7 +939,7 @@ void ThreadMapPort2(void* parg) freeUPNPDevlist(devlist); devlist = 0; FreeUPNPUrls(&urls); loop { - if (fShutdown) + if (fShutdown || !fUseUPnP) return; Sleep(2000); } From f285d4f4f395d7a69f182ddb35ec48c8b10da2d2 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 16 Apr 2011 11:35:45 -0700 Subject: [PATCH 2/2] Fix for #156: UPnP segfault when no valid UPnP IGDs are found. --- net.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net.cpp b/net.cpp index f3857baf61..a403655660 100644 --- a/net.cpp +++ b/net.cpp @@ -906,7 +906,8 @@ void ThreadMapPort2(void* parg) struct IGDdatas data; int r; - if (UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)) == 1) + r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); + if (r == 1) { char intClient[16]; char intPort[6]; @@ -937,7 +938,8 @@ void ThreadMapPort2(void* parg) } else { printf("No valid UPnP IGDs found\n"); freeUPNPDevlist(devlist); devlist = 0; - FreeUPNPUrls(&urls); + if (r != 0) + FreeUPNPUrls(&urls); loop { if (fShutdown || !fUseUPnP) return;