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

index e8349a0..3ac5216 100644 (file)
@@ -266,7 +266,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;
@@ -305,7 +306,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;