diff options
author | Mike Lockwood <lockwood@android.com> | 2011-03-15 13:20:58 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-03-15 13:20:58 -0700 |
commit | afd1c0143dfa63bd133e3a4163cc9cc4216e3514 (patch) | |
tree | a9578c77ef397708e5a0463844b326bd31436e9d | |
parent | 1d233d9708e39f5b57b231746df658567b153484 (diff) | |
parent | b0f72de87d1abdfec0cd188f277c48f65f7011a8 (diff) | |
download | frameworks_base-afd1c0143dfa63bd133e3a4163cc9cc4216e3514.zip frameworks_base-afd1c0143dfa63bd133e3a4163cc9cc4216e3514.tar.gz frameworks_base-afd1c0143dfa63bd133e3a4163cc9cc4216e3514.tar.bz2 |
Merge "SqliteDatabase: Fix local reference leak in custom_function_callback()" into honeycomb-mr1
-rw-r--r-- | core/jni/android_database_SQLiteDatabase.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/core/jni/android_database_SQLiteDatabase.cpp b/core/jni/android_database_SQLiteDatabase.cpp index a5878a9..e0c900e 100644 --- a/core/jni/android_database_SQLiteDatabase.cpp +++ b/core/jni/android_database_SQLiteDatabase.cpp @@ -64,7 +64,7 @@ enum { static jfieldID offset_db_handle; static jmethodID method_custom_function_callback; -static jclass string_class = NULL; +static jclass string_class; static jint sSqliteSoftHeapLimit = 0; 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); // 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); if (!strArray) 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->DeleteLocalRef(strArray); done: if (env->ExceptionCheck()) { @@ -489,6 +488,12 @@ int register_android_database_SQLiteDatabase(JNIEnv *env) 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"); if (offset_db_handle == NULL) { LOGE("Can't find SQLiteDatabase.mNativeHandle\n"); |