Fix for #156: UPnP segfault when no valid UPnP IGDs are found.

This commit is contained in:
Dan Helfman 2011-04-16 11:35:45 -07:00 committed by Matt Corallo
parent 973800b52f
commit f285d4f4f3

View file

@ -906,7 +906,8 @@ void ThreadMapPort2(void* parg)
struct IGDdatas data; struct IGDdatas data;
int r; 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 intClient[16];
char intPort[6]; char intPort[6];
@ -937,6 +938,7 @@ void ThreadMapPort2(void* parg)
} else { } else {
printf("No valid UPnP IGDs found\n"); printf("No valid UPnP IGDs found\n");
freeUPNPDevlist(devlist); devlist = 0; freeUPNPDevlist(devlist); devlist = 0;
if (r != 0)
FreeUPNPUrls(&urls); FreeUPNPUrls(&urls);
loop { loop {
if (fShutdown || !fUseUPnP) if (fShutdown || !fUseUPnP)