This patchset is to avoid ArgumentNullException error. There are some
cases to come NULL variable from Native API.
BluetoothAdapterImpl.cs: RegisterDiscoveryStateChangedEvent(258) > Discovery state changed callback is called
Unhandled exception.
System.ArgumentNullException: Value cannot be null. (Parameter 'ptr')
at System.Runtime.InteropServices.Marshal.PtrToStringAnsi(IntPtr ptr, Int32 len)
at Tizen.Network.Bluetooth.BluetoothUtils.ConvertStructToDiscoveredDevice(BluetoothDiscoveredDeviceStruct structDevice)
at Tizen.Network.Bluetooth.BluetoothAdapterImpl.<RegisterDiscoveryStateChangedEvent>b__45_0(Int32 result, BluetoothDeviceDiscoveryState state, IntPtr deviceInfo, IntPtr user
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
resultDevice.RemoteDeviceService = uuidList;
resultDevice.RemoteDeviceCount = device.ServiceCount;
resultDevice.RemoteManufLength = device.ManufacturerDataLength;
- resultDevice.RemoteManufData = Marshal.PtrToStringAnsi(device.ManufacturerData, device.ManufacturerDataLength);
+
+ if (device.ManufacturerData != IntPtr.Zero)
+ resultDevice.RemoteManufData = Marshal.PtrToStringAnsi(device.ManufacturerData, device.ManufacturerDataLength);
return resultDevice;
}
}
resultDevice.RemotePaired = structDevice.IsPaired;
- resultDevice.RemoteManufData = Marshal.PtrToStringAnsi(structDevice.ManufacturerData, structDevice.ManufacturerDataLength);
resultDevice.RemoteManufLength = structDevice.ManufacturerDataLength;
+
+ if (structDevice.ManufacturerData != IntPtr.Zero)
+ resultDevice.RemoteManufData = Marshal.PtrToStringAnsi(structDevice.ManufacturerData, structDevice.ManufacturerDataLength);
+
return resultDevice;
}