Merge "SqliteDatabase: Fix local reference leak in custom_function_callback()" into honeycomb-mr1
This commit is contained in:
committed by
Android (Google) Code Review
commit
afd1c0143d
@ -64,7 +64,7 @@ enum {
|
|||||||
|
|
||||||
static jfieldID offset_db_handle;
|
static jfieldID offset_db_handle;
|
||||||
static jmethodID method_custom_function_callback;
|
static jmethodID method_custom_function_callback;
|
||||||
static jclass string_class = NULL;
|
static jclass string_class;
|
||||||
static jint sSqliteSoftHeapLimit = 0;
|
static jint sSqliteSoftHeapLimit = 0;
|
||||||
|
|
||||||
static char *createStr(const char *path, short extra) {
|
static char *createStr(const char *path, short extra) {
|
||||||
@ -406,8 +406,6 @@ static void custom_function_callback(sqlite3_context * context, int argc, sqlite
|
|||||||
jobject function = (jobject)sqlite3_user_data(context);
|
jobject function = (jobject)sqlite3_user_data(context);
|
||||||
|
|
||||||
// pack up the arguments into a string array
|
// pack up the arguments into a string array
|
||||||
if (!string_class)
|
|
||||||
string_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/String"));
|
|
||||||
jobjectArray strArray = env->NewObjectArray(argc, string_class, NULL);
|
jobjectArray strArray = env->NewObjectArray(argc, string_class, NULL);
|
||||||
if (!strArray)
|
if (!strArray)
|
||||||
goto done;
|
goto done;
|
||||||
@ -425,6 +423,7 @@ static void custom_function_callback(sqlite3_context * context, int argc, sqlite
|
|||||||
}
|
}
|
||||||
|
|
||||||
env->CallVoidMethod(function, method_custom_function_callback, strArray);
|
env->CallVoidMethod(function, method_custom_function_callback, strArray);
|
||||||
|
env->DeleteLocalRef(strArray);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (env->ExceptionCheck()) {
|
if (env->ExceptionCheck()) {
|
||||||
@ -489,6 +488,12 @@ int register_android_database_SQLiteDatabase(JNIEnv *env)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/String"));
|
||||||
|
if (string_class == NULL) {
|
||||||
|
LOGE("Can't find java/lang/String\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
offset_db_handle = env->GetFieldID(clazz, "mNativeHandle", "I");
|
offset_db_handle = env->GetFieldID(clazz, "mNativeHandle", "I");
|
||||||
if (offset_db_handle == NULL) {
|
if (offset_db_handle == NULL) {
|
||||||
LOGE("Can't find SQLiteDatabase.mNativeHandle\n");
|
LOGE("Can't find SQLiteDatabase.mNativeHandle\n");
|
||||||
|
Reference in New Issue
Block a user