[ros-diffs] [janderwald] 40058: - Fix memory leak - Fix memory corruptions - Does not fix es1370mp / es1371mp driver (qemu / vmware)

janderwald at svn.reactos.org janderwald at svn.reactos.org
Mon Mar 16 14:12:15 CET 2009


Author: janderwald
Date: Mon Mar 16 16:12:14 2009
New Revision: 40058

URL: http://svn.reactos.org/svn/reactos?rev=40058&view=rev
Log:
- Fix memory leak
- Fix memory corruptions
- Does not fix es1370mp / es1371mp driver (qemu / vmware)

Modified:
    trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c
    trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c?rev=40058&r1=40057&r2=40058&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/port_topology.c [iso-8859-1] Mon Mar 16 16:12:14 2009
@@ -468,10 +468,11 @@
         DPRINT("Pin %p\n", Pin);
     }
 
-    DPRINT1("CreatePinWorkerRoutine completing irp\n");
+    DPRINT1("CreatePinWorkerRoutine completing irp %p\n", WorkerContext->Irp);
     WorkerContext->Irp->IoStatus.Status = Status;
     WorkerContext->Irp->IoStatus.Information = 0;
     IoCompleteRequest(WorkerContext->Irp, IO_SOUND_INCREMENT);
+    ExFreePool(WorkerContext);
 }
 
 

Modified: trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c?rev=40058&r1=40057&r2=40058&view=diff
==============================================================================
--- trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/wdm/audio/backpln/portcls/resource.c [iso-8859-1] Mon Mar 16 16:12:14 2009
@@ -215,10 +215,24 @@
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
-    RtlCopyMemory(NewTranslatedResources, This->TranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
+    RtlCopyMemory(NewTranslatedResources, This->TranslatedResourceList, sizeof(CM_RESOURCE_LIST));
+    if (This->TranslatedResourceList[0].List->PartialResourceList.Count > 1)
+    {
+        RtlCopyMemory(&NewTranslatedResources->List[0].PartialResourceList.PartialDescriptors[0],
+                      &This->TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[0], 
+                      sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * This->TranslatedResourceList->List[0].PartialResourceList.Count);
+    }
+
     RtlCopyMemory(&NewTranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->TranslatedResourceList[0].List->PartialResourceList.Count], Translated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
 
-    RtlCopyMemory(NewUntranslatedResources, This->UntranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
+    RtlCopyMemory(NewUntranslatedResources, This->UntranslatedResourceList, sizeof(CM_RESOURCE_LIST));
+    if (This->UntranslatedResourceList[0].List->PartialResourceList.Count > 1)
+    {
+        RtlCopyMemory(&NewUntranslatedResources->List[0].PartialResourceList.PartialDescriptors[0],
+                      &This->UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[0], 
+                      sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * This->UntranslatedResourceList->List[0].PartialResourceList.Count);
+    }
+
     RtlCopyMemory(&NewUntranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->UntranslatedResourceList[0].List->PartialResourceList.Count], Untranslated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
 
     FreeItem(This->TranslatedResourceList, TAG_PORTCLASS);
@@ -255,7 +269,14 @@
     if (!NewTranslatedResources)
         return STATUS_INSUFFICIENT_RESOURCES;
 
-    RtlCopyMemory(NewTranslatedResources, This->TranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (This->TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
+    RtlCopyMemory(NewTranslatedResources, This->TranslatedResourceList, sizeof(CM_RESOURCE_LIST));
+    if (This->TranslatedResourceList[0].List->PartialResourceList.Count > 1)
+    {
+        RtlCopyMemory(&NewTranslatedResources->List[0].PartialResourceList.PartialDescriptors[0],
+                      &This->TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[0], 
+                      sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * This->TranslatedResourceList->List[0].PartialResourceList.Count);
+    }
+
     RtlCopyMemory(&NewTranslatedResources->List[0].PartialResourceList.PartialDescriptors[This->TranslatedResourceList[0].List->PartialResourceList.Count], Translated, sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
 
     FreeItem(This->TranslatedResourceList, TAG_PORTCLASS);
@@ -336,7 +357,10 @@
 
     /* Initialize */
 
-    NewTranslatedSize = sizeof(CM_RESOURCE_LIST) + (TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+    NewTranslatedSize = sizeof(CM_RESOURCE_LIST);
+    if (TranslatedResourceList[0].List->PartialResourceList.Count > 1)
+        NewTranslatedSize += (TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+
     NewTranslatedResources = AllocateItem(PoolType, NewTranslatedSize, TAG_PORTCLASS);
     if (!NewTranslatedResources)
     {
@@ -344,7 +368,10 @@
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
-    NewUntranslatedSize = sizeof(CM_RESOURCE_LIST) + (UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+    NewUntranslatedSize = sizeof(CM_RESOURCE_LIST);
+    if (UntranslatedResourceList[0].List->PartialResourceList.Count > 1)
+        NewUntranslatedSize += (UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
+
     NewUntranslatedResources = AllocateItem(PoolType, NewUntranslatedSize, TAG_PORTCLASS);
     if (!NewUntranslatedResources)
     {
@@ -353,8 +380,8 @@
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
-    RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (TranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
-    RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, sizeof(CM_RESOURCE_LIST) + (UntranslatedResourceList[0].List->PartialResourceList.Count-1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
+    RtlCopyMemory(NewTranslatedResources, TranslatedResourceList, NewTranslatedSize);
+    RtlCopyMemory(NewUntranslatedResources, UntranslatedResourceList, NewUntranslatedSize);
 
     NewList->lpVtbl = (IResourceListVtbl*)&vt_ResourceListVtbl;
     NewList->ref = 1;



More information about the Ros-diffs mailing list