Author: tfaber
Date: Mon May 9 17:44:16 2016
New Revision: 71301
URL:
http://svn.reactos.org/svn/reactos?rev=71301&view=rev
Log:
[USBHUB]
- Fix memory leak in failure case of CreateDeviceIds. Patch by Víctor Martínez Calvo. CID
1102364
CORE-11208 #resolve
Modified:
trunk/reactos/drivers/usb/usbhub/fdo.c
Modified: trunk/reactos/drivers/usb/usbhub/fdo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbhub/fdo.c?r…
==============================================================================
--- trunk/reactos/drivers/usb/usbhub/fdo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/usb/usbhub/fdo.c [iso-8859-1] Mon May 9 17:44:16 2016
@@ -1035,6 +1035,9 @@
{
// construct instance id buffer
Index = swprintf(Buffer, L"%04d&%s",
HubDeviceExtension->InstanceCount, SerialBuffer) + 1;
+
+ ExFreePool(SerialBuffer);
+
UsbChildExtension->usInstanceId.Buffer =
(LPWSTR)ExAllocatePool(NonPagedPool, Index * sizeof(WCHAR));
if (UsbChildExtension->usInstanceId.Buffer == NULL)
{
@@ -1047,7 +1050,6 @@
//
RtlCopyMemory(UsbChildExtension->usInstanceId.Buffer, Buffer, Index *
sizeof(WCHAR));
UsbChildExtension->usInstanceId.Length =
UsbChildExtension->usInstanceId.MaximumLength = Index * sizeof(WCHAR);
- ExFreePool(SerialBuffer);
DPRINT("Usb InstanceId %wZ InstanceCount %x\n",
&UsbChildExtension->usInstanceId, HubDeviceExtension->InstanceCount);
return Status;