mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-03 07:45:35 +00:00
Added more error checking to the T-Balancer enumeration code. This hopefully fixes an IndexOutOfRangeException in the TBalancerGroup constructor.
This commit is contained in:
@@ -51,14 +51,25 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
|
|
||||||
uint numDevices;
|
uint numDevices;
|
||||||
try {
|
try {
|
||||||
FTD2XX.FT_CreateDeviceInfoList(out numDevices);
|
if (FTD2XX.FT_CreateDeviceInfoList(out numDevices) != FT_STATUS.FT_OK) {
|
||||||
|
report.AppendLine("Status: FT_CreateDeviceInfoList failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch (DllNotFoundException) { return; }
|
} catch (DllNotFoundException) { return; }
|
||||||
catch (ArgumentNullException) { return; }
|
catch (ArgumentNullException) { return; }
|
||||||
catch (EntryPointNotFoundException) { return; }
|
catch (EntryPointNotFoundException) { return; }
|
||||||
catch (BadImageFormatException) { return; }
|
catch (BadImageFormatException) { return; }
|
||||||
|
|
||||||
FT_DEVICE_INFO_NODE[] info = new FT_DEVICE_INFO_NODE[numDevices];
|
FT_DEVICE_INFO_NODE[] info = new FT_DEVICE_INFO_NODE[numDevices];
|
||||||
FTD2XX.FT_GetDeviceInfoList(info, ref numDevices);
|
if (FTD2XX.FT_GetDeviceInfoList(info, ref numDevices) != FT_STATUS.FT_OK)
|
||||||
|
{
|
||||||
|
report.AppendLine("Status: FT_GetDeviceInfoList failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure numDevices is not larger than the info array
|
||||||
|
if (numDevices > info.Length)
|
||||||
|
numDevices = (uint)info.Length;
|
||||||
|
|
||||||
for (int i = 0; i < numDevices; i++) {
|
for (int i = 0; i < numDevices; i++) {
|
||||||
report.Append("Device Index: ");
|
report.Append("Device Index: ");
|
||||||
|
Reference in New Issue
Block a user