[PATCH] iphlpapi: Simplify the calculation of "ptr" in CreateSortedAddressPairs().
Henri Verbeet
hverbeet at codeweavers.com
Sun Aug 9 06:13:52 CDT 2015
Note that there's an (arguably subtle) bug in the original; "pairs" is casted
to a SOCKADDR_IN6 pointer before the offset is applied.
---
dlls/iphlpapi/iphlpapi_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index b6ab612..4b1261a 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -387,7 +387,7 @@ DWORD WINAPI CreateSortedAddressPairs( const PSOCKADDR_IN6 src_list, DWORD src_c
size = dst_count * sizeof(*pairs);
size += dst_count * sizeof(SOCKADDR_IN6) * 2; /* source address + destination address */
if (!(pairs = HeapAlloc( GetProcessHeap(), 0, size ))) return ERROR_NOT_ENOUGH_MEMORY;
- ptr = (SOCKADDR_IN6 *)(char *)pairs + dst_count * sizeof(*pairs);
+ ptr = (SOCKADDR_IN6 *)&pairs[dst_count];
if ((ret = getIPAddrTable( &table, GetProcessHeap(), 0 )))
{
--
2.1.4
More information about the wine-patches
mailing list