Handle some failure cases in better way.
authorFilip Navara <filip.navara@gmail.com>
Thu, 22 Sep 2005 20:36:07 +0000 (20:36 +0000)
committerFilip Navara <filip.navara@gmail.com>
Thu, 22 Sep 2005 20:36:07 +0000 (20:36 +0000)
svn path=/trunk/; revision=17986

reactos/lib/iphlpapi/ifenum_reactos.c

index fbd7ac4..25e0834 100644 (file)
@@ -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,
                 }
             }
         }
-    }
 
-    *infoSet = infoSetInt;
-    *numInterfaces = curInterf;
+        if (NT_SUCCESS(status)) {
+            *infoSet = infoSetInt;
+            *numInterfaces = curInterf;
+        } else {
+            HeapFree(GetProcessHeap(), 0, infoSetInt);
+        }
 
-    return STATUS_SUCCESS;
+        return status;
+    } else {
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
 }
 
 static DWORD getNumInterfacesInt(BOOL onlyNonLoopback)