summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2022-12-12 12:46:56 -0800
committerChih-hung Hsieh <chh@google.com>2023-01-10 00:49:46 +0000
commit92ce070084f1a2cbd2c2d13c87df388db81be898 (patch)
treec91b7cee58cec366433cf0fe02190b774e3d54d2
parent6ce98521cc081e4b91168da69d005b6cd952fbe8 (diff)
downloadcar-main-16k-with-phones.tar.gz
Fix potential memory leaksmain-16k-with-phones
Bug: 259995529 Test: make tidy-device-generic-car_subset Change-Id: I910286e058dfbbfe62eb8ae84f79a9acfa62abb5
-rw-r--r--emulator/usbpt/bluetooth/usb_modeswitch/usb_modeswitch.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/emulator/usbpt/bluetooth/usb_modeswitch/usb_modeswitch.c b/emulator/usbpt/bluetooth/usb_modeswitch/usb_modeswitch.c
index 3b7c48b..9b092ee 100644
--- a/emulator/usbpt/bluetooth/usb_modeswitch/usb_modeswitch.c
+++ b/emulator/usbpt/bluetooth/usb_modeswitch/usb_modeswitch.c
@@ -1707,13 +1707,13 @@ struct libusb_device* search_devices( int *numFound, int vendor, char* productLi
if (!vendor || *productList == '\0')
return NULL;
- listcopy = malloc(strlen(productList)+1);
-
if (libusb_get_device_list(ctx, &devs) < 0) {
perror("Libusb failed to get USB access!");
return 0;
}
+ listcopy = malloc(strlen(productList)+1);
+
while ((dev = devs[i++]) != NULL) {
struct libusb_device_descriptor descriptor;
libusb_get_device_descriptor(dev, &descriptor);