[Bluetooth][Non-ACR] Add device name null check logic (#3084)
authorWootak Jung <wootak.jung@samsung.com>
Wed, 26 May 2021 04:10:34 +0000 (13:10 +0900)
committerGitHub <noreply@github.com>
Wed, 26 May 2021 04:10:34 +0000 (13:10 +0900)
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothStructs.cs

index 85c3b41..b5f32ea 100644 (file)
@@ -271,7 +271,8 @@ namespace Tizen.Network.Bluetooth
             }
 
             resultDevice.RemoteDeviceAddress = device.Address;
-            resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(device.Name, DeviceNameLengthMax);
+            if (device.Name != IntPtr.Zero)
+                resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(device.Name, DeviceNameLengthMax);
             resultDevice.RemoteDeviceClass = new BluetoothClass();
             resultDevice.Class.MajorType = device.Class.MajorDeviceClassType;
             resultDevice.Class.MinorType = device.Class.MinorDeviceClassType;
@@ -310,7 +311,8 @@ namespace Tizen.Network.Bluetooth
             }
 
             resultDevice.RemoteDeviceAddress = structDevice.Address;
-            resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(structDevice.Name, DeviceNameLengthMax);
+            if (structDevice.Name != IntPtr.Zero)
+                resultDevice.RemoteDeviceName = Marshal.PtrToStringAnsi(structDevice.Name, DeviceNameLengthMax);
 
             resultDevice.RemoteDeviceClass = new BluetoothClass();
             resultDevice.Class.MajorType = structDevice.Class.MajorDeviceClassType;