In JNI, we should always call Release...(), no matter what isCopy says.

git-svn-id: svn://10.0.0.236/trunk@168099 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pedemont%us.ibm.com
2005-01-20 23:59:10 +00:00
parent 9f240d50dd
commit 7517748139
3 changed files with 12 additions and 27 deletions

View File

@@ -178,18 +178,15 @@ XPCOM_NATIVE(newLocalFile) (JNIEnv *env, jclass, jstring aPath,
jboolean aFollowLinks)
{
// Create a Mozilla string from the jstring
jboolean isCopy;
const PRUnichar* buf = nsnull;
if (aPath) {
buf = env->GetStringChars(aPath, &isCopy);
buf = env->GetStringChars(aPath, nsnull);
if (!buf)
return nsnull; // exception already thrown
}
nsAutoString path_str(buf);
if (isCopy) {
env->ReleaseStringChars(aPath, buf);
}
env->ReleaseStringChars(aPath, buf);
// Make call to given function
nsILocalFile* file = nsnull;
@@ -477,13 +474,11 @@ XPCOMPRIVATE_NATIVE(FinalizeStub) (JNIEnv *env, jclass that,
jobject aJavaObject)
{
#ifdef DEBUG_pedemonte
jboolean isCopy;
jclass clazz = env->GetObjectClass(aJavaObject);
jstring name = (jstring) env->CallObjectMethod(clazz, getNameMID);
const char* javaObjectName = env->GetStringUTFChars(name, &isCopy);
const char* javaObjectName = env->GetStringUTFChars(name, nsnull);
LOG(("*** Finalize(java_obj=%s)\n", javaObjectName));
if (isCopy)
env->ReleaseStringUTFChars(name, javaObjectName);
env->ReleaseStringUTFChars(name, javaObjectName);
#endif
void* obj = gBindings->GetXPCOMObject(env, aJavaObject);