Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[usb/usbview] Fix memory leak when handling enumeration error cases #1222

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions usb/usbview/uvcview.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ typedef struct _DEVICE_GUID_LIST {
G L O B A L S
*****************************************************************************/

#if !defined(UVCVIEW_DISABLE_GLOBALS)

//
// USBVIEW.C
//
Expand Down Expand Up @@ -429,6 +431,8 @@ PUSB_CONFIGURATION_DESCRIPTOR g_pConfigDesc;
PSTRING_DESCRIPTOR_NODE g_pStringDescs;
PUCHAR g_descEnd;

#endif

/*****************************************************************************
F U N C T I O N P R O T O T Y P E S
*****************************************************************************/
Expand Down