Fix possible nullreference with usb devices.

This commit is contained in:
2019-10-18 22:44:02 +01:00
parent e51f95e4f0
commit e2251750a2

View File

@@ -462,8 +462,10 @@ namespace DiscImageChef.Devices
if (Directory.Exists("/sys/block/" + devPath)) if (Directory.Exists("/sys/block/" + devPath))
{ {
var resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath); var resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
resolvedLink = "/sys" + resolvedLink.Substring(2);
if (!string.IsNullOrEmpty(resolvedLink)) if (!string.IsNullOrEmpty(resolvedLink))
{
resolvedLink = "/sys" + resolvedLink.Substring(2);
while (resolvedLink.Contains("usb")) while (resolvedLink.Contains("usb"))
{ {
resolvedLink = Path.GetDirectoryName(resolvedLink); resolvedLink = Path.GetDirectoryName(resolvedLink);
@@ -518,6 +520,7 @@ namespace DiscImageChef.Devices
} }
} }
} }
}
break; break;
case PlatformID.Win32NT: case PlatformID.Win32NT: