diff options
author | Elliott Hughes <enh@google.com> | 2009-10-26 11:18:00 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2009-10-26 11:33:40 -0700 |
commit | 4baf5edc579de0e8bec439185b496d3e9aacfad9 (patch) | |
tree | c8ca7333757f6b18cbccf671c8291273314d7f4b /sql | |
parent | e73b98c37f2c61cf5f4de43a1df75229d911572e (diff) | |
download | libcore-4baf5edc579de0e8bec439185b496d3e9aacfad9.zip libcore-4baf5edc579de0e8bec439185b496d3e9aacfad9.tar.gz libcore-4baf5edc579de0e8bec439185b496d3e9aacfad9.tar.bz2 |
DeleteLocalRef the result of GetObjectClass more consistently.
Should fix VM crashes in tests.java.sql.StressTest, which can now be
re-enabled.
I've also added a "throwoom" to the one place where this code
calls malloc but doesn't check the result.
Bug: 2213053
Diffstat (limited to 'sql')
-rw-r--r-- | sql/src/main/native/sqlite_jni.c | 14 | ||||
-rwxr-xr-x | sql/src/test/java/tests/java/sql/StressTest.java | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/sql/src/main/native/sqlite_jni.c b/sql/src/main/native/sqlite_jni.c index 1a23769..341ef2e 100644 --- a/sql/src/main/native/sqlite_jni.c +++ b/sql/src/main/native/sqlite_jni.c @@ -320,6 +320,10 @@ trans2iso(JNIEnv *env, int haveutf, jstring enc, jstring src, if (haveutf) { const jsize utfLength = (*env)->GetStringUTFLength(env, src); dest->result = dest->tofree = malloc(utfLength + 1); + if (!dest->tofree) { + throwoom(env, "string translation failed"); + return dest->result; + } (*env)->GetStringUTFRegion(env, src, 0, utfLength, dest->result); return dest->result; } @@ -399,6 +403,7 @@ busyhandler(void *udata, const char *table, int count) "(Ljava/lang/String;I)Z"); if (mid == 0) { + (*env)->DeleteLocalRef(env, cls); return ret; } trans2utf(env, h->haveutf, h->enc, table, &tabstr); @@ -406,6 +411,7 @@ busyhandler(void *udata, const char *table, int count) (jint) count) != JNI_FALSE; (*env)->DeleteLocalRef(env, tabstr.jstr); + (*env)->DeleteLocalRef(env, cls); } return ret; } @@ -425,10 +431,12 @@ busyhandler3(void *udata, int count) "(Ljava/lang/String;I)Z"); if (mid == 0) { + (*env)->DeleteLocalRef(env, cls); return ret; } ret = (*env)->CallBooleanMethod(env, h->bh, mid, 0, (jint) count) != JNI_FALSE; + (*env)->DeleteLocalRef(env, cls); } return ret; } @@ -446,9 +454,11 @@ progresshandler(void *udata) jmethodID mid = (*env)->GetMethodID(env, cls, "progress", "()Z"); if (mid == 0) { + (*env)->DeleteLocalRef(env, cls); return ret; } ret = (*env)->CallBooleanMethod(env, h->ph, mid) != JNI_TRUE; + (*env)->DeleteLocalRef(env, cls); } return ret; } @@ -1591,6 +1601,7 @@ call_common(sqlite_func *sf, int isstep, int nargs, const char **args) int i; if (mid == 0) { + (*env)->DeleteLocalRef(env, cls); return; } arr = (*env)->NewObjectArray(env, nargs, C_java_lang_String, 0); @@ -1639,6 +1650,7 @@ call_final(sqlite_func *sf) jmethodID mid = (*env)->GetMethodID(env, cls, "last_step", "(LSQLite/FunctionContext;)V"); if (mid == 0) { + (*env)->DeleteLocalRef(env, cls); return; } f->sf = sf; @@ -1665,6 +1677,7 @@ call3_common(sqlite3_context *sf, int isstep, int nargs, sqlite3_value **args) int i; if (mid == 0) { + (*env)->DeleteLocalRef(env, cls); return; } arr = (*env)->NewObjectArray(env, nargs, C_java_lang_String, 0); @@ -1714,6 +1727,7 @@ call3_final(sqlite3_context *sf) jmethodID mid = (*env)->GetMethodID(env, cls, "last_step", "(LSQLite/FunctionContext;)V"); if (mid == 0) { + (*env)->DeleteLocalRef(env, cls); return; } f->sf = sf; diff --git a/sql/src/test/java/tests/java/sql/StressTest.java b/sql/src/test/java/tests/java/sql/StressTest.java index 8b80690..b6d13c1 100755 --- a/sql/src/test/java/tests/java/sql/StressTest.java +++ b/sql/src/test/java/tests/java/sql/StressTest.java @@ -219,7 +219,6 @@ public class StressTest extends TestCase { clazz = Driver.class, args = {String.class, Properties.class} ) - @BrokenTest("2191557 ReferenceTable overflow") public void testInsertOfManyRowsUsingManyThreads() { Logger.global.info("java.sql stress test: multiple threads and many operations."); |