From 098d1afc0a158542559095b363de76fc843e7433 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Sat, 18 Jul 2020 01:04:10 +0200 Subject: [PATCH] Fix memory leak in usb_interface_descriptor error path usbi_reallocf() will leak memory if passed pointer has members to free. Change-Id: I183dce6067905c92a1cf373e67902244c52e9fed Signed-off-by: lokilee73 --- libusb/descriptor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libusb/descriptor.c b/libusb/descriptor.c index 4c9435f..da34b38 100644 --- a/libusb/descriptor.c +++ b/libusb/descriptor.c @@ -228,7 +228,8 @@ static int parse_interface(libusb_context *ctx, while (size >= INTERFACE_DESC_LENGTH) { struct libusb_interface_descriptor *altsetting = (struct libusb_interface_descriptor *) usb_interface->altsetting; - altsetting = usbi_reallocf(altsetting, + /* can't use usbi_realloc() as we need to free libusb_interface_descriptor members - see clear_interface() */ + altsetting = realloc(altsetting, sizeof(struct libusb_interface_descriptor) * (usb_interface->num_altsetting + 1)); if (!altsetting) { -- 2.7.4