Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 641010 - crash [@ libdvm.so@0x35790][@ libdvm.so@0x35748 ][@ libd…

…vm.so@0x35784 ][@ libdvm.so@0x357d0 ]. The way we were creating new java strings was leaky in a few places, and non-null terminated in others. This could/does results in a bunch of random crashes that will not show up in crash reporter. Basically, if you want to always make sure that you have a local frame and never use our low level string apis that don't terminate when creating java strings. r=mwu a=sheriff

--HG--
extra : rebase_source : 738907fefb747c5259e7ca53a53cae9ecf75b105
  • Loading branch information...
commit f4a5493bf2520720f4b620727e51eac53c0af0f5 1 parent 34c4c35
@dougt dougt authored
Showing with 19 additions and 22 deletions.
  1. +19 −22 widget/src/android/AndroidBridge.cpp
View
41 widget/src/android/AndroidBridge.cpp
@@ -390,9 +390,9 @@ AndroidBridge::GetHandlersForMimeType(const char *aMimeType,
NS_ConvertUTF8toUTF16 wMimeType(aMimeType);
jstring jstrMimeType =
mJNIEnv->NewString(wMimeType.get(), wMimeType.Length());
- const PRUnichar* wAction;
- PRUint32 actionLen = NS_StringGetData(aAction, &wAction);
- jstring jstrAction = mJNIEnv->NewString(wAction, actionLen);
+
+ jstring jstrAction = mJNIEnv->NewString(nsPromiseFlatString(aAction).get(),
+ aAction.Length());
jobject obj = mJNIEnv->CallStaticObjectMethod(mGeckoAppShellClass,
jGetHandlersForMimeType,
@@ -423,9 +423,8 @@ AndroidBridge::GetHandlersForURL(const char *aURL,
AutoLocalJNIFrame jniFrame;
NS_ConvertUTF8toUTF16 wScheme(aURL);
jstring jstrScheme = mJNIEnv->NewString(wScheme.get(), wScheme.Length());
- const PRUnichar* wAction;
- PRUint32 actionLen = NS_StringGetData(aAction, &wAction);
- jstring jstrAction = mJNIEnv->NewString(wAction, actionLen);
+ jstring jstrAction = mJNIEnv->NewString(nsPromiseFlatString(aAction).get(),
+ aAction.Length());
jobject obj = mJNIEnv->CallStaticObjectMethod(mGeckoAppShellClass,
jGetHandlersForURL,
@@ -454,21 +453,18 @@ AndroidBridge::OpenUriExternal(const nsACString& aUriSpec, const nsACString& aMi
AutoLocalJNIFrame jniFrame;
NS_ConvertUTF8toUTF16 wUriSpec(aUriSpec);
NS_ConvertUTF8toUTF16 wMimeType(aMimeType);
- const PRUnichar* wPackageName;
- PRUint32 packageNameLen = NS_StringGetData(aPackageName, &wPackageName);
- const PRUnichar* wClassName;
- PRUint32 classNameLen = NS_StringGetData(aClassName, &wClassName);
- const PRUnichar* wAction;
- PRUint32 actionLen = NS_StringGetData(aAction, &wAction);
- const PRUnichar* wTitle;
- PRUint32 titleLen = NS_StringGetData(aTitle, &wTitle);
jstring jstrUri = mJNIEnv->NewString(wUriSpec.get(), wUriSpec.Length());
jstring jstrType = mJNIEnv->NewString(wMimeType.get(), wMimeType.Length());
- jstring jstrPackage = mJNIEnv->NewString(wPackageName, packageNameLen);
- jstring jstrClass = mJNIEnv->NewString(wClassName, classNameLen);
- jstring jstrAction = mJNIEnv->NewString(wAction, actionLen);
- jstring jstrTitle = mJNIEnv->NewString(wTitle, titleLen);
+
+ jstring jstrPackage = mJNIEnv->NewString(nsPromiseFlatString(aPackageName).get(),
+ aPackageName.Length());
+ jstring jstrClass = mJNIEnv->NewString(nsPromiseFlatString(aClassName).get(),
+ aClassName.Length());
+ jstring jstrAction = mJNIEnv->NewString(nsPromiseFlatString(aAction).get(),
+ aAction.Length());
+ jstring jstrTitle = mJNIEnv->NewString(nsPromiseFlatString(aTitle).get(),
+ aTitle.Length());
return mJNIEnv->CallStaticBooleanMethod(mGeckoAppShellClass,
jOpenUriExternal,
@@ -535,10 +531,9 @@ void
AndroidBridge::SetClipboardText(const nsAString& aText)
{
ALOG_BRIDGE("AndroidBridge::SetClipboardText");
-
- const PRUnichar* wText;
- PRUint32 wTextLen = NS_StringGetData(aText, &wText);
- jstring jstr = mJNIEnv->NewString(wText, wTextLen);
+ AutoLocalJNIFrame jniFrame;
+ jstring jstr = mJNIEnv->NewString(nsPromiseFlatString(aText).get(),
+ aText.Length());
mJNIEnv->CallStaticObjectMethod(mGeckoAppShellClass, jSetClipboardText, jstr);
}
@@ -677,6 +672,7 @@ void
AndroidBridge::SetSelectedLocale(const nsAString& aLocale)
{
ALOG_BRIDGE("AndroidBridge::SetSelectedLocale");
+ AutoLocalJNIFrame jniFrame;
jstring jLocale = GetJNIForThread()->NewString(PromiseFlatString(aLocale).get(), aLocale.Length());
GetJNIForThread()->CallStaticVoidMethod(mGeckoAppShellClass, jSetSelectedLocale, jLocale);
}
@@ -855,6 +851,7 @@ jclass GetGeckoAppShellClass()
void
AndroidBridge::ScanMedia(const nsAString& aFile, const nsACString& aMimeType)
{
+ AutoLocalJNIFrame jniFrame;
jstring jstrFile = mJNIEnv->NewString(nsPromiseFlatString(aFile).get(), aFile.Length());
nsString mimeType2;
Please sign in to comment.
Something went wrong with that request. Please try again.