Skip to content

Commit 4be1e0b

Browse files
blackspherefollowerqdot
authored andcommitted
Adding null checking to the event and advertisement.
1 parent 81d0d96 commit 4be1e0b

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Buttplug.Server.Managers.UWPBluetoothManager/UWPBluetoothManager.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ public UWPBluetoothManager(IButtplugLogManager aLogManager)
5858
private async void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher aObj,
5959
BluetoothLEAdvertisementReceivedEventArgs aEvent)
6060
{
61-
var advertName = aEvent.Advertisement.LocalName;
61+
if (aEvent == null || aEvent.Advertisement == null)
62+
{
63+
BpLogger.Debug("Null BLE advertisement recieved: skipping");
64+
return;
65+
}
66+
67+
var advertName = aEvent.Advertisement.LocalName ?? string.Empty;
6268
var advertGUIDs = new List<Guid>();
63-
advertGUIDs.AddRange(aEvent.Advertisement.ServiceUuids);
69+
advertGUIDs.AddRange(aEvent.Advertisement.ServiceUuids ?? new Guid[] { });
6470
var btAddr = aEvent.BluetoothAddress;
6571

6672
// BpLogger.Trace($"Got BLE Advertisement for device: {aEvent.Advertisement.LocalName} / {aEvent.BluetoothAddress}");

0 commit comments

Comments
 (0)