mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-27 04:25:12 +00:00
Now we clamp the list to 2 and make count to 0 to avoid leaks + adding loggin
This commit is contained in:
parent
0763601d35
commit
5a1c420b2c
@ -44,18 +44,16 @@ void PS4_SYSV_ABI sceUsbdExit() {
|
|||||||
s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list) {
|
s64 PS4_SYSV_ABI sceUsbdGetDeviceList(SceUsbdDevice*** list) {
|
||||||
LOG_DEBUG(Lib_Usbd, "called");
|
LOG_DEBUG(Lib_Usbd, "called");
|
||||||
|
|
||||||
static ssize_t last_count = -1;
|
|
||||||
|
|
||||||
ssize_t count = libusb_get_device_list(g_libusb_context, list);
|
ssize_t count = libusb_get_device_list(g_libusb_context, list);
|
||||||
if (count <= 0)
|
if (count < 0)
|
||||||
return libusb_to_orbis_error((int)count);
|
return libusb_to_orbis_error((int)count);
|
||||||
|
|
||||||
if (count != last_count) {
|
if (count > 2)
|
||||||
LOG_INFO(Lib_Usbd, "Found {} USB devices", count);
|
LOG_WARNING(Lib_Usbd, "Too Many USB Devices Connected");
|
||||||
last_count = count;
|
libusb_unref_device((*list)[2]);
|
||||||
}
|
count = 0;
|
||||||
|
|
||||||
return ORBIS_OK;
|
return libusb_to_orbis_error((int)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices) {
|
void PS4_SYSV_ABI sceUsbdFreeDeviceList(SceUsbdDevice** list, s32 unref_devices) {
|
||||||
|
Loading…
Reference in New Issue
Block a user