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

Unified Diff: base/android/build_info.cc

Issue 1866023002: [Android] Handle null values in BuildInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698