added cleaning up of local references to jobjects in jni.c (DeleteLocalRef)
@@ -103,6 +103,10 @@ static int call1Arg (Data * data, Key * errorKey, const char * method)
(*data->env)->CallVoidMethod (data->env, jerrorKey, data->midKeyDecRef);
checkException (data, method, errorKey);
+ // clean up local references
+ (*data->env)->DeleteLocalRef (data->env, jerrorKey);
+ checkException (data, method, errorKey);
+
return result;
}
@@ -144,6 +148,12 @@ static int call2Arg (Data * data, KeySet * ks, Key * errorKey, const char * meth
(*data->env)->CallVoidMethod (data->env, jkey, data->midKeyDecRef);
checkException (data, method, errorKey);
+ // clean up local references
+ (*data->env)->DeleteLocalRef (data->env, jkey);
+ checkException (data, method, errorKey);
+ (*data->env)->DeleteLocalRef (data->env, jks);
+ checkException (data, method, errorKey);
+
return result;
}
@@ -323,6 +333,10 @@ int elektraJniClose (Plugin * handle, Key * errorKey)
int ret = call1Arg (data, errorKey, "close");
+ // clean up local references
+ (*data->env)->DeleteLocalRef (data->env, data->plugin);
+ checkException (data, "close", errorKey);
+
(*data->jvm)->DestroyJavaVM (data->jvm);
elektraFree (data);
