Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: jni/JniJsValue.cpp

Issue 4761138508070912: Issue 1848 - Clean up local reference handling (Closed)
Patch Set: More formatting issues Created Feb. 4, 2015, 12:03 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « jni/JniFilterEngine.cpp ('k') | jni/JniLogSystem.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jni/JniJsValue.cpp
diff --git a/jni/JniJsValue.cpp b/jni/JniJsValue.cpp
index 2cf5478c2c3391f831a45a697731716b4eb621d6..6b9fb0f627f25ce0d7c959afa0bb9914579564e7 100644
--- a/jni/JniJsValue.cpp
+++ b/jni/JniJsValue.cpp
@@ -144,7 +144,14 @@ jobject NewJniJsValue(JNIEnv* env, const AdblockPlus::JsValuePtr& jsValue, jclas
jclass clazz = jsValueClass ? jsValueClass : env->FindClass(PKG("JsValue"));
jmethodID ctor = env->GetMethodID(clazz, "<init>", "(J)V");
jlong ptr = JniPtrToLong(new AdblockPlus::JsValuePtr(jsValue));
- return env->NewObject(clazz, ctor, ptr);
+ jobject ret = env->NewObject(clazz, ctor, ptr);
+
+ if (!jsValueClass)
+ {
+ env->DeleteLocalRef(clazz);
+ }
+
+ return ret;
}
AdblockPlus::JsValue* JniGetJsValue(jlong ptr)
@@ -163,7 +170,8 @@ jobject JniJsValueListToArrayList(JNIEnv* env, AdblockPlus::JsValueList& list)
for (AdblockPlus::JsValueList::iterator it = list.begin(), end = list.end(); it != end; ++it)
{
- JniAddObjectToList(env, arrayList, NewJniJsValue(env, *it));
+ JniAddObjectToList(env, arrayList,
+ *JniLocalReference<jobject>(env, NewJniJsValue(env, *it)));
}
return arrayList;
« no previous file with comments | « jni/JniFilterEngine.cpp ('k') | jni/JniLogSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld