[ros-diffs] [cgutman] 53190: [IPHLPAPI] - Fix a massive memory leak of our entire TDI entity ID database after each call to getInterfaceInfoSet - Fix another massive leak of our entire TDI interface table afte...

cgutman at svn.reactos.org cgutman at svn.reactos.org
Fri Aug 12 08:12:49 UTC 2011


Author: cgutman
Date: Fri Aug 12 08:12:47 2011
New Revision: 53190

URL: http://svn.reactos.org/svn/reactos?rev=53190&view=rev
Log:
[IPHLPAPI]
- Fix a massive memory leak of our entire TDI entity ID database after each call to getInterfaceInfoSet
- Fix another massive leak of our entire TDI interface table after each call to getInterfaceInfoByIndex and getInterfaceInfoByName
- Fix some uninitialized variable warnings
- Explorer no longer leaks horrendous amounts of memory (about 1 MB per minute even without network activity) when the network status icon is in the system tray

Modified:
    trunk/reactos/dll/win32/iphlpapi/ifenum_reactos.c

Modified: trunk/reactos/dll/win32/iphlpapi/ifenum_reactos.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/iphlpapi/ifenum_reactos.c?rev=53190&r1=53189&r2=53190&view=diff
==============================================================================
--- trunk/reactos/dll/win32/iphlpapi/ifenum_reactos.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/iphlpapi/ifenum_reactos.c [iso-8859-1] Fri Aug 12 08:12:47 2011
@@ -202,6 +202,8 @@
             }
         }
 
+        tdiFreeThingSet(entIDSet);
+
         if (NT_SUCCESS(status)) {
             *infoSet = infoSetInt;
             *numInterfaces = curInterf;
@@ -285,12 +287,12 @@
     TRACE("Index %d is entity #%d - %04x:%08x\n", index, i,
            entitySet[i].tei_entity, entitySet[i].tei_instance );
 
+    tdiFreeThingSet( entitySet );
+
     if( numInterfaces == index && i < numEntities ) {
         memcpy( ent, &entitySet[i], sizeof(*ent) );
-        tdiFreeThingSet( entitySet );
         return STATUS_SUCCESS;
     } else {
-        tdiFreeThingSet( entitySet );
         return STATUS_UNSUCCESSFUL;
     }
 }
@@ -302,6 +304,7 @@
     int i;
 
     if( NT_SUCCESS(status) )
+    {
         for( i = 0; i < numInterfaces; i++ ) {
             if( ifInfo[i].if_info.ent.if_index == index ) {
                 memcpy( info, &ifInfo[i], sizeof(*info) );
@@ -309,10 +312,12 @@
             }
         }
 
-    if( NT_SUCCESS(status) )
+        HeapFree(GetProcessHeap(), 0, ifInfo);
+
         return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
-    else
-        return status;
+    }
+
+    return status;
 }
 
 NTSTATUS getInterfaceInfoByName( HANDLE tcpFile, char *name, IFInfo *info ) {
@@ -322,6 +327,7 @@
     NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces );
 
     if( NT_SUCCESS(status) )
+    {
         for( i = 0; i < numInterfaces; i++ ) {
             if( !strcmp((PCHAR)ifInfo[i].if_info.ent.if_descr, name) ) {
                 memcpy( info, &ifInfo[i], sizeof(*info) );
@@ -329,10 +335,12 @@
             }
         }
 
-    if( NT_SUCCESS(status) )
+        HeapFree(GetProcessHeap(), 0,ifInfo);
+
         return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
-    else
-        return status;
+    }
+
+    return status;
 }
 
 /* Note that the result of this operation must be freed later */




More information about the Ros-diffs mailing list