Author: janderwald
Date: Mon Dec 1 07:54:25 2008
New Revision: 37789
URL:
http://svn.reactos.org/svn/reactos?rev=37789&view=rev
Log:
- fix ipconfig output when no nic adapter is present, patch by Lucas Suggs, <anakha AT
cat DOT pdx DOT edu>
- bug 3928
- fix a few memory leaks
Modified:
trunk/reactos/base/applications/network/ipconfig/ipconfig.c
Modified: trunk/reactos/base/applications/network/ipconfig/ipconfig.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/ipconfig/ipconfig.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/ipconfig/ipconfig.c [iso-8859-1] Mon Dec 1
07:54:25 2008
@@ -360,15 +360,18 @@
ULONG adaptOutBufLen = 0;
PFIXED_INFO pFixedInfo = NULL;
ULONG netOutBufLen = 0;
+ ULONG ret = 0;
/* call GetAdaptersInfo to obtain the adapter info */
- if (GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen) == ERROR_BUFFER_OVERFLOW)
+ ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
+ if (ret == ERROR_BUFFER_OVERFLOW)
{
pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
if (pAdapterInfo == NULL)
return;
- if (GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen) != NO_ERROR)
+ ret = GetAdaptersInfo(pAdapterInfo, &adaptOutBufLen);
+ if (ret != NO_ERROR)
{
DoFormatMessage(0);
HeapFree(ProcessHeap, 0, pAdapterInfo);
@@ -377,8 +380,11 @@
}
else
{
- DoFormatMessage(0);
- return;
+ if( ERROR_NO_DATA != ret )
+ {
+ DoFormatMessage(0);
+ return;
+ }
}
/* call GetNetworkParams to obtain the network info */
@@ -386,17 +392,24 @@
{
pFixedInfo = (FIXED_INFO *)HeapAlloc(ProcessHeap, 0, netOutBufLen);
if (pFixedInfo == NULL)
+ {
+ if (pAdapterInfo)
+ HeapFree(ProcessHeap, 0, pAdapterInfo);
return;
if (GetNetworkParams(pFixedInfo, &netOutBufLen) != NO_ERROR)
{
DoFormatMessage(0);
+ if (pAdapterInfo)
+ HeapFree(ProcessHeap, 0, pAdapterInfo);
HeapFree(ProcessHeap, 0, pFixedInfo);
return;
}
}
else
{
+ if (pAdapterInfo)
+ HeapFree(ProcessHeap, 0, pAdapterInfo);
DoFormatMessage(0);
return;
}
@@ -413,7 +426,7 @@
_tprintf(_T("\tIP Routing Enabled. . . . . . . . : Yes\n"));
else
_tprintf(_T("\tIP Routing Enabled. . . . . . . . : No\n"));
- if (pAdapter->HaveWins)
+ if (pAdapter && pAdapter->HaveWins)
_tprintf(_T("\tWINS Proxy enabled. . . . . . . . : Yes\n"));
else
_tprintf(_T("\tWINS Proxy enabled. . . . . . . . : No\n"));
@@ -494,7 +507,8 @@
}
HeapFree(ProcessHeap, 0, pFixedInfo);
- HeapFree(ProcessHeap, 0, pAdapterInfo);
+ if (pAdapterInfo)
+ HeapFree(ProcessHeap, 0, pAdapterInfo);
}
VOID Release(LPTSTR Index)