[SQLiteJDBC] Segfault when reading NULL string column

Adam B adamb at videx.com
Tue Jun 1 14:57:48 EDT 2010


Hello all,

We just started using sqlitejdbc v56 and it's been working great so 
far.  However, we've encountered a segfault condition in NativeDB.c.  To 
reproduce, simply create a table with a TEXT column and insert a NULL 
into it.  Now try to read the value using ResultSet.getString(int).  
I've tracked the problem down to NativeDB.c:442:

    JNIEXPORT jstring JNICALL Java_org_sqlite_NativeDB_column_1text(
            JNIEnv *env, jobject this, jlong stmt, jint col)
    {
        return (*env)->NewStringUTF(
            env, (const char*)sqlite3_column_text(toref(stmt), col));
    }


The problem is that sqlite3_column_text() apparently returns NULL for a 
NULL column value and NewStringUTF blows up on it.  Perhaps Sun's JVM 
gracefully tolerates a NULL argument to NewStringUTF but we are using 
JamVM which does not.  It's an easy fix though.

Regards
- Adam


Videx Inc. 1105 N. E. Circle Blvd. Corvallis OR 97330 (541) 758-0521
CONFIDENTIAL COMMUNICATION: The email message and any attachments are intended only for the addressee.  They may be privileged, confidential, and protected from disclosure. If you are not the intended recipient, any dissemination, distribution, or copying is expressly prohibited.  If you received this email message in error, please notify the sender immediately by replying to this e-mail message or by telephone




More information about the SQLiteJDBC mailing list