Index: jni/JniFilterEngine.cpp |
diff --git a/jni/JniFilterEngine.cpp b/jni/JniFilterEngine.cpp |
index 7976902711d9e59dd5038bce35cea432d6b40876..07adbb873636eb12dc398eeeaf2a39e99735c118 100644 |
--- a/jni/JniFilterEngine.cpp |
+++ b/jni/JniFilterEngine.cpp |
@@ -34,11 +34,11 @@ static jobject SubscriptionsToArrayList(JNIEnv* env, std::vector<AdblockPlus::Su |
static AdblockPlus::FilterEngine::ContentType ConvertContentType(JNIEnv *env, |
jobject jContentType) |
{ |
- jclass contentTypeClass = env->GetObjectClass(jContentType); |
- jmethodID nameMethod = env->GetMethodID(contentTypeClass, "name", |
+ JniLocalReference<jclass> contentTypeClass(env, env->GetObjectClass(jContentType)); |
+ jmethodID nameMethod = env->GetMethodID(*contentTypeClass, "name", |
"()Ljava/lang/String;"); |
- jstring jValue = (jstring) env->CallObjectMethod(jContentType, nameMethod); |
- const std::string value = JniJavaToStdString(env, jValue); |
+ JniLocalReference<jstring> jValue(env, (jstring) env->CallObjectMethod(jContentType, nameMethod)); |
+ const std::string value = JniJavaToStdString(env, *jValue); |
return AdblockPlus::FilterEngine::StringToContentType(value); |
} |
@@ -94,7 +94,7 @@ static jobject JNICALL JniGetListedFilters(JNIEnv* env, jclass clazz, jlong ptr) |
for (std::vector<AdblockPlus::FilterPtr>::iterator it = filters.begin(), end = filters.end(); it != end; it++) |
{ |
- JniAddObjectToList(env, list, NewJniFilter(env, *it)); |
+ JniAddObjectToList(env, list, *JniLocalReference<jobject>(env, NewJniFilter(env, *it))); |
} |
return list; |
@@ -234,7 +234,7 @@ static jobject JNICALL JniGetElementHidingSelectors(JNIEnv* env, jclass clazz, j |
for (std::vector<std::string>::iterator it = selectors.begin(), end = selectors.end(); it != end; it++) |
{ |
- JniAddObjectToList(env, list, env->NewStringUTF(it->c_str())); |
+ JniAddObjectToList(env, list, *JniLocalReference<jstring>(env, env->NewStringUTF(it->c_str()))); |
} |
return list; |
@@ -274,7 +274,8 @@ static jobject JNICALL JniMatchesMany(JNIEnv* env, jclass clazz, jlong ptr, jstr |
for (jsize i = 0; i < len; i++) |
{ |
- documentUrls.push_back(JniJavaToStdString(env, static_cast<jstring>(env->GetObjectArrayElement(jDocumentUrls, i)))); |
+ documentUrls.push_back(JniJavaToStdString(env, |
+ *JniLocalReference<jstring>(env, static_cast<jstring>(env->GetObjectArrayElement(jDocumentUrls, i))))); |
} |
try |