Bug in NativeDB.c bind_1blob

Issue #84 new
Anonymous created an issue

Code in Java_org_sqlite_NativeDB_bind_1blob incorrectly wraps a call to (env)->GetPrimitiveArrayCritical(env, v, 0) in an assert. If debugging is turned off, this call is omitted, and the subsequent call to (env)->ReleasePrimitiveArrayCritical(env, v, a, JNI_ABORT) is wrong.

Fix: change the code:

jint rc;
jsize size = (*env)->GetArrayLength(env, v);
void* a = (*env)->GetPrimitiveArrayCritical(env, v, 0);
rc = sqlite3_bind_blob(toref(stmt), pos, a, size, SQLITE_TRANSIENT);
(*env)->ReleasePrimitiveArrayCritical(env, v, a, JNI_ABORT);
return rc;

(and possibly check for other asserts wrapping functions-with-side effects)

Comments (0)

  1. Log in to comment