[Sumover-dev] [svn commit] r4473 - common/trunk/src
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Tue Jun 30 14:25:03 BST 2009
Author: piers
Date: Tue Jun 30 14:25:02 2009
New Revision: 4473
Modified:
common/trunk/src/net_udp.c
Log:
Fixed inappropriate free() of the allinfo (A problem when it is set to the address of the oneinfo variable)
Modified: common/trunk/src/net_udp.c
==============================================================================
--- common/trunk/src/net_udp.c (original)
+++ common/trunk/src/net_udp.c Tue Jun 30 14:25:02 2009
@@ -839,12 +839,16 @@
route.dwForwardIfIndex);
len = sizeof(oneinfo);
+ // Make initial call - which can return an error if there's not enough
+ // space and will set len to required size
if (GetAdaptersInfo(&oneinfo, &len) == ERROR_SUCCESS)
{
debug_msg("got allinfo in one\n");
allinfo = &oneinfo;
}
else
+ // Call again with appropriately (larger) sized buffer
+ // (Assuming the first call returns ERROR_BUFFER_OVERFLOW)
{
allinfo = (PIP_ADAPTER_INFO) malloc(len);
if (GetAdaptersInfo(allinfo, &len) != ERROR_SUCCESS)
@@ -877,7 +881,8 @@
}
}
}
- free(allinfo);
+ if (allinfo != &oneinfo)
+ free(allinfo);
}
#if 0 /* This is the stuff that just works on XP, sigh. */
len = sizeof(addrs);
@@ -957,6 +962,8 @@
}
}
}
+ if (allinfo != &oneinfo)
+ free(allinfo);
}
} else {
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
More information about the Sumover-dev
mailing list