summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/bridge/jni/v8
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-09-02 10:06:59 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-02 10:06:59 -0700
commite3edcfcfc731bd5051947d8c0a4b2685e7cae84d (patch)
tree6057a7bff33f8a23f9e3ccc341bd1be201e73649 /Source/WebCore/bridge/jni/v8
parent06fc99abf07271f62be9b535061f37d43b269057 (diff)
parent70a54261052a5a78a33b5b91d4f3ab699b55e2ef (diff)
downloadexternal_webkit-e3edcfcfc731bd5051947d8c0a4b2685e7cae84d.zip
external_webkit-e3edcfcfc731bd5051947d8c0a4b2685e7cae84d.tar.gz
external_webkit-e3edcfcfc731bd5051947d8c0a4b2685e7cae84d.tar.bz2
Merge "Fix the Java bridge to correctly handle null strings"
Diffstat (limited to 'Source/WebCore/bridge/jni/v8')
-rw-r--r--Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
index a731fe1..42efaac 100644
--- a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
+++ b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
@@ -353,6 +353,13 @@ void convertJavaValueToNPVariant(JavaValue value, NPVariant* result)
case JavaTypeString:
{
+#if PLATFORM(ANDROID)
+ // This entire file will likely be removed usptream soon.
+ if (value.m_stringValue.isNull()) {
+ VOID_TO_NPVARIANT(*result);
+ break;
+ }
+#endif
const char* utf8String = strdup(value.m_stringValue.utf8().data());
// The copied string is freed in NPN_ReleaseVariantValue (see npruntime.cpp)
STRINGZ_TO_NPVARIANT(utf8String, *result);
@@ -430,6 +437,10 @@ JavaValue jvalueToJavaValue(const jvalue& value, const JavaType& type)
case JavaTypeString:
{
jstring javaString = static_cast<jstring>(value.l);
+ if (!javaString) {
+ // result.m_stringValue is null by default
+ break;
+ }
const UChar* characters = getUCharactersFromJStringInEnv(getJNIEnv(), javaString);
// We take a copy to allow the Java String to be released.
result.m_stringValue = String(characters, getJNIEnv()->GetStringLength(javaString));
@@ -488,6 +499,10 @@ jvalue javaValueToJvalue(const JavaValue& value)
// be released when the call stack returns to Java. Note that this
// may cause leaks if invoked from a native message loop, as is the
// case in workers.
+ if (value.m_stringValue.isNull()) {
+ // result.l is null by default.
+ break;
+ }
result.l = getJNIEnv()->NewString(value.m_stringValue.characters(), value.m_stringValue.length());
break;
case JavaTypeBoolean: