From 7b828505b973f0676d523aef533c5f0b82fe6af0 Mon Sep 17 00:00:00 2001 From: slavek1250 Date: Thu, 26 Sep 2024 23:27:51 +0200 Subject: [PATCH 1/4] fix: memory leak when handling error case in EnumerateHub and EnumerateHubPorts --- usb/usbview/enum.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/usb/usbview/enum.c b/usb/usbview/enum.c index 297e0d320..6c22344f5 100644 --- a/usb/usbview/enum.c +++ b/usb/usbview/enum.c @@ -951,6 +951,16 @@ EnumerateHub ( FREE(ConnectionInfo); } + if (ConnectionInfoV2) + { + FREE(ConnectionInfoV2); + } + + if (PortConnectorProps) + { + FREE(PortConnectorProps); + } + if (ConfigDesc) { FREE(ConfigDesc); @@ -973,6 +983,16 @@ EnumerateHub ( } while (StringDescs != NULL); } + + if(DevProps) + { + FreeDeviceProperties(&DevProps); + } + + if (hubCapabilityEx) + { + FREE(hubCapabilityEx); + } } //***************************************************************************** @@ -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; } From baff952bfc8329fd6016c561e72f7da3145e184a Mon Sep 17 00:00:00 2001 From: slavek1250 Date: Sat, 5 Oct 2024 12:44:01 +0200 Subject: [PATCH 2/4] feat: make usb device info structure named --- usb/usbview/uvcview.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/usbview/uvcview.h b/usb/usbview/uvcview.h index 6f7424624..f2d3529bc 100644 --- a/usb/usbview/uvcview.h +++ b/usb/usbview/uvcview.h @@ -330,7 +330,7 @@ typedef struct _USBEXTERNALHUBINFO // HubInfo, HubName may be in USBDEVICEINFOTYPE, so they can be removed -typedef struct +typedef struct _USBDEVICEINFO { USBDEVICEINFOTYPE DeviceInfoType; PUSB_NODE_INFORMATION HubInfo; // NULL if not a HUB From b85633a98432a5c1deccd73e771ea82a1b9e09ae Mon Sep 17 00:00:00 2001 From: slavek1250 Date: Wed, 6 Nov 2024 18:29:22 +0100 Subject: [PATCH 3/4] feat: conditionally disable globals in header file to be able to include it into multiple cpp files --- usb/usbview/uvcview.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usb/usbview/uvcview.h b/usb/usbview/uvcview.h index f2d3529bc..ade0a9749 100644 --- a/usb/usbview/uvcview.h +++ b/usb/usbview/uvcview.h @@ -369,6 +369,8 @@ typedef struct _DEVICE_GUID_LIST { G L O B A L S *****************************************************************************/ +#if !defined(UVCVIEW_DISABLE_GLOBALS) + // // USBVIEW.C // @@ -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 *****************************************************************************/ From 97f3d096bacdd9813ccb88f140b7fa5f82ae22cc Mon Sep 17 00:00:00 2001 From: slavek1250 Date: Fri, 8 Nov 2024 21:21:44 +0100 Subject: [PATCH 4/4] revert: feat: make usb device info structure named --- usb/usbview/uvcview.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/usbview/uvcview.h b/usb/usbview/uvcview.h index ade0a9749..ab2da2100 100644 --- a/usb/usbview/uvcview.h +++ b/usb/usbview/uvcview.h @@ -330,7 +330,7 @@ typedef struct _USBEXTERNALHUBINFO // HubInfo, HubName may be in USBDEVICEINFOTYPE, so they can be removed -typedef struct _USBDEVICEINFO +typedef struct { USBDEVICEINFOTYPE DeviceInfoType; PUSB_NODE_INFORMATION HubInfo; // NULL if not a HUB