From 5aab768c19e37782d33cd23b4c666c6467a0251f Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 22 Sep 2005 20:36:07 +0000 Subject: [PATCH] Handle some failure cases in better way. svn path=/trunk/; revision=17986 --- reactos/lib/iphlpapi/ifenum_reactos.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/reactos/lib/iphlpapi/ifenum_reactos.c b/reactos/lib/iphlpapi/ifenum_reactos.c index fbd7ac4181f..25e0834de63 100644 --- a/reactos/lib/iphlpapi/ifenum_reactos.c +++ b/reactos/lib/iphlpapi/ifenum_reactos.c @@ -304,13 +304,14 @@ static BOOL isInterface( TDIEntityID *if_maybe ) { static BOOL isLoopback( HANDLE tcpFile, TDIEntityID *loop_maybe ) { IFEntrySafelySized entryInfo; + NTSTATUS status; - tdiGetMibForIfEntity( tcpFile, - loop_maybe, - &entryInfo ); + status = tdiGetMibForIfEntity( tcpFile, + loop_maybe, + &entryInfo ); - return !entryInfo.ent.if_type || - entryInfo.ent.if_type == IFENT_SOFTWARE_LOOPBACK; + return NT_SUCCESS(status) && (!entryInfo.ent.if_type || + entryInfo.ent.if_type == IFENT_SOFTWARE_LOOPBACK); } NTSTATUS tdiGetEntityType( HANDLE tcpFile, TDIEntityID *ent, PULONG type ) { @@ -388,12 +389,18 @@ static NTSTATUS getInterfaceInfoSet( HANDLE tcpFile, } } } + + if (NT_SUCCESS(status)) { + *infoSet = infoSetInt; + *numInterfaces = curInterf; + } else { + HeapFree(GetProcessHeap(), 0, infoSetInt); + } + + return status; + } else { + return STATUS_INSUFFICIENT_RESOURCES; } - - *infoSet = infoSetInt; - *numInterfaces = curInterf; - - return STATUS_SUCCESS; } static DWORD getNumInterfacesInt(BOOL onlyNonLoopback)