Index: base/android/build_info.cc |
diff --git a/base/android/build_info.cc b/base/android/build_info.cc |
index 2d3ef278ee2585315147e8f18a520c6e21e3a2c5..5fa6c6c7ea8248b6f6d916bc37dbf170dad5c698 100644 |
--- a/base/android/build_info.cc |
+++ b/base/android/build_info.cc |
@@ -16,8 +16,15 @@ |
namespace { |
-// The caller takes ownership of the returned const char*. |
+// We are leaking these strings. |
const char* StrDupJString(const base::android::JavaRef<jstring>& java_string) { |
+ // Some of the Java methods on BuildInfo can return null |
+ // (https://crbug.com/601081), which can't be represented as a std::string, so |
+ // use an empty string instead. |
+ // TODO(bauerb): Do this only for methods that can legitimately return null. |
+ if (java_string.is_null()) |
+ return ""; |
+ |
std::string str = ConvertJavaStringToUTF8(java_string); |
return strdup(str.c_str()); |
} |