diff options
author | Jay Freeman <saurik@saurik.com> | 2008-02-06 01:21:28 +0000 |
---|---|---|
committer | Jay Freeman <saurik@saurik.com> | 2008-02-06 01:21:28 +0000 |
commit | 8e60af7ad00762fb8a89ae39c771287f3c5efed4 (patch) | |
tree | 0a619a46907a3e1d605253150248cf5b7d18cc80 /data/javasqlite | |
parent | dbf028b6725a6681995b9e457f1a9baff1ac82ef (diff) |
I found a bug in Apple's SQLite3, but I fixed it in JavaSQLite for now.
git-svn-id: http://svn.telesphoreo.org/trunk@73 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'data/javasqlite')
-rw-r--r-- | data/javasqlite/null16.diff | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/data/javasqlite/null16.diff b/data/javasqlite/null16.diff new file mode 100644 index 000000000..64c2905c0 --- /dev/null +++ b/data/javasqlite/null16.diff @@ -0,0 +1,67 @@ +diff -ru javasqlite-20071108/native/sqlite_jni.c javasqlite-20071108+iPhone/native/sqlite_jni.c +--- javasqlite-20071108/native/sqlite_jni.c 2007-10-27 06:58:54.000000000 +0000 ++++ javasqlite-20071108+iPhone/native/sqlite_jni.c 2008-02-06 01:18:37.000000000 +0000 +@@ -3346,6 +3346,8 @@ + jsize len16; + const jchar *sql16, *tail = 0; + int ret; ++ int i; ++ jchar *sql2; + + if (!h) { + throwclosed(env); +@@ -3371,11 +3373,15 @@ + } + h->env = env; + sql16 = (*env)->GetStringChars(env, sql, 0); ++ sql2 = malloc(len16 + sizeof(jchar)); ++ memcpy(sql2, sql16, len16); ++ sql2[len16 / sizeof(jchar)] = '\0'; ++ (*env)->ReleaseStringChars(env, sql, sql16); + #if HAVE_SQLITE3_PREPARE16_V2 +- ret = sqlite3_prepare16_v2((sqlite3 *) h->sqlite, sql16, len16, ++ ret = sqlite3_prepare16_v2((sqlite3 *) h->sqlite, sql2, len16, + (sqlite3_stmt **) &svm, (const void **) &tail); + #else +- ret = sqlite3_prepare16((sqlite3 *) h->sqlite, sql16, len16, ++ ret = sqlite3_prepare16((sqlite3 *) h->sqlite, sql2, len16, + (sqlite3_stmt **) &svm, (const void **) &tail); + #endif + if (ret != SQLITE_OK) { +@@ -3387,22 +3393,23 @@ + if (ret != SQLITE_OK) { + const char *err = sqlite3_errmsg(h->sqlite); + +- (*env)->ReleaseStringChars(env, sql, sql16); ++ free(sql2); + setstmterr(env, stmt, ret); ++ printf("%s\n", err); + throwex(env, err ? err : "error in prepare"); + return; + } + if (!svm) { +- (*env)->ReleaseStringChars(env, sql, sql16); ++ free(sql2); + return; + } +- len16 = len16 + sizeof (jchar) - ((char *) tail - (char *) sql16); ++ len16 = len16 + sizeof (jchar) - ((char *) tail - (char *) sql2); + if (len16 < sizeof (jchar)) { + len16 = sizeof (jchar); + } + v = malloc(sizeof (hvm) + len16); + if (!v) { +- (*env)->ReleaseStringChars(env, sql, sql16); ++ free(sql2); + sqlite3_finalize((sqlite3_stmt *) svm); + throwoom(env, "unable to get SQLite handle"); + return; +@@ -3418,7 +3425,7 @@ + memcpy(v->tail, tail, len16); + len16 /= sizeof (jchar); + ((jchar *) v->tail)[len16 - 1] = 0; +- (*env)->ReleaseStringChars(env, sql, sql16); ++ free(sql2); + v->hh.sqlite = 0; + v->hh.haveutf = h->haveutf; + v->hh.ver = h->ver; |