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

Unified Diff: base/android/jni_string.cc

Issue 1913183002: Allow null jstring to C++ string conversions in release. (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/jni_string.cc
diff --git a/base/android/jni_string.cc b/base/android/jni_string.cc
index c24ab36ab5ec35795478e5ca659778fc9ed563f7..f28f6498ece95f400f2a34981030e4693dfac22a 100644
--- a/base/android/jni_string.cc
+++ b/base/android/jni_string.cc
@@ -25,6 +25,11 @@ namespace android {
void ConvertJavaStringToUTF8(JNIEnv* env, jstring str, std::string* result) {
DCHECK(str);
+ if (!str) {
+ LOG(WARNING) << "ConvertJavaStringToUTF8 called with null string.";
Bernhard Bauer 2016/04/22 20:29:17 FWIW, I probably would have done this with a NOTRE
+ result->clear();
+ return;
+ }
const jsize length = env->GetStringLength(str);
if (!length) {
result->clear();
@@ -71,6 +76,11 @@ ScopedJavaLocalRef<jstring> ConvertUTF8ToJavaString(
void ConvertJavaStringToUTF16(JNIEnv* env, jstring str, string16* result) {
DCHECK(str);
+ if (!str) {
+ LOG(WARNING) << "ConvertJavaStringToUTF16 called with null string.";
+ result->clear();
+ return;
+ }
const jsize length = env->GetStringLength(str);
if (!length) {
result->clear();
« 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