Skip to content

Commit 8b1c8cc

Browse files
authored
Fix app crash if MAC address is empty, return empty string (BornToBeRoot#467)
Co-authored-by: BornToBeRoot <BornToBeRoot@users.noreply.github.com>
1 parent b8870f3 commit 8b1c8cc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Source/NETworkManager.Converters/PhysicalAddressToStringConverter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ public sealed class PhysicalAddressToStringConverter : IValueConverter
1010
{
1111
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1212
{
13-
return value == null ? string.Empty : MACAddressHelper.GetDefaultFormat((PhysicalAddress)value);
13+
if (!(value is PhysicalAddress physicalAddress))
14+
return string.Empty;
15+
16+
string macAddress = physicalAddress.ToString();
17+
18+
return string.IsNullOrEmpty(macAddress) ? string.Empty : MACAddressHelper.GetDefaultFormat(macAddress);
1419
}
1520

1621
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

0 commit comments

Comments
 (0)