Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: device/bluetooth/bluetooth_device_android.cc

Issue 1897873003: bluetooth: Check if device name is null before trying to convert (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_device_android.cc
diff --git a/device/bluetooth/bluetooth_device_android.cc b/device/bluetooth/bluetooth_device_android.cc
index 61497323f2ab9b035f7928414ead34850a64202f..8e5b2ec261b06a9fd32393c37fa0a5df47327094 100644
--- a/device/bluetooth/bluetooth_device_android.cc
+++ b/device/bluetooth/bluetooth_device_android.cc
@@ -281,8 +281,13 @@ BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
: BluetoothDevice(adapter) {}
std::string BluetoothDeviceAndroid::GetDeviceName() const {
- return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
- AttachCurrentThread(), j_device_.obj()));
+ auto device_name = Java_ChromeBluetoothDevice_getDeviceName(
+ AttachCurrentThread(), j_device_.obj());
+
+ if (device_name.is_null()) {
+ return "";
+ }
+ return ConvertJavaStringToUTF8(device_name);
}
void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698