Skip to content

Commit 7b82850

Browse files
committed
fix: memory leak when handling error case in EnumerateHub and EnumerateHubPorts
1 parent 616b191 commit 7b82850

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

usb/usbview/enum.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,16 @@ EnumerateHub (
951951
FREE(ConnectionInfo);
952952
}
953953

954+
if (ConnectionInfoV2)
955+
{
956+
FREE(ConnectionInfoV2);
957+
}
958+
959+
if (PortConnectorProps)
960+
{
961+
FREE(PortConnectorProps);
962+
}
963+
954964
if (ConfigDesc)
955965
{
956966
FREE(ConfigDesc);
@@ -973,6 +983,16 @@ EnumerateHub (
973983

974984
} while (StringDescs != NULL);
975985
}
986+
987+
if(DevProps)
988+
{
989+
FreeDeviceProperties(&DevProps);
990+
}
991+
992+
if (hubCapabilityEx)
993+
{
994+
FREE(hubCapabilityEx);
995+
}
976996
}
977997

978998
//*****************************************************************************
@@ -1367,6 +1387,24 @@ EnumerateHubPorts (
13671387
{
13681388
FREE(connectionInfoExV2);
13691389
}
1390+
1391+
if (stringDescs != NULL)
1392+
{
1393+
PSTRING_DESCRIPTOR_NODE Next;
1394+
1395+
do {
1396+
1397+
Next = stringDescs->Next;
1398+
FREE(stringDescs);
1399+
stringDescs = Next;
1400+
1401+
} while (stringDescs != NULL);
1402+
}
1403+
1404+
if(DevProps)
1405+
{
1406+
FreeDeviceProperties(&DevProps);
1407+
}
13701408
break;
13711409
}
13721410

0 commit comments

Comments
 (0)