Skip to content

Commit

Permalink
fix: memory leak when handling error case in EnumerateHub and Enumera…
Browse files Browse the repository at this point in the history
…teHubPorts
  • Loading branch information
dkala97 committed Sep 26, 2024
1 parent 616b191 commit 7b82850
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions usb/usbview/enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,16 @@ EnumerateHub (
FREE(ConnectionInfo);
}

if (ConnectionInfoV2)
{
FREE(ConnectionInfoV2);
}

if (PortConnectorProps)
{
FREE(PortConnectorProps);
}

if (ConfigDesc)
{
FREE(ConfigDesc);
Expand All @@ -973,6 +983,16 @@ EnumerateHub (

} while (StringDescs != NULL);
}

if(DevProps)
{
FreeDeviceProperties(&DevProps);
}

if (hubCapabilityEx)
{
FREE(hubCapabilityEx);
}
}

//*****************************************************************************
Expand Down Expand Up @@ -1367,6 +1387,24 @@ EnumerateHubPorts (
{
FREE(connectionInfoExV2);
}

if (stringDescs != NULL)
{
PSTRING_DESCRIPTOR_NODE Next;

do {

Next = stringDescs->Next;
FREE(stringDescs);
stringDescs = Next;

} while (stringDescs != NULL);
}

if(DevProps)
{
FreeDeviceProperties(&DevProps);
}
break;
}

Expand Down

0 comments on commit 7b82850

Please sign in to comment.