sqlcipher/android-database-sqlcipher

java.lang.NullPointerException on SQLiteDatabase.delete(SQLiteDatabase.java:2267)

mittt opened this issue · 2 comments

mittt commented

After updating from 4.2.0 to 4.3.0, I'm getting the following exception:
java.lang.NullPointerException: Attempt to get length of null array
at net.sqlcipher.database.SQLiteDatabase.delete(SQLiteDatabase.java:2267)

When calling db.delete("TABLENAME", null, null);

When you check the code, the error looks obvious:

    public int delete(String table, String whereClause, String[] whereArgs) {
        Object[] args = new Object[whereArgs.length];

Expected Behavior

To delete all rows as documented: "Passing null will delete all rows."

Actual Behavior

Exception:
java.lang.NullPointerException: Attempt to get length of null array
at net.sqlcipher.database.SQLiteDatabase.delete(SQLiteDatabase.java:2267)

Steps to Reproduce

db.delete("TABLENAME", null, null);

SQLCipher version (can be identified by executing PRAGMA cipher_version;):
implementation 'net.zetetic:android-database-sqlcipher:4.3.0'
implementation "androidx.sqlite:sqlite:2.0.1"
SQLCipher for Android version: 9.0

My fault! I apologize for messing that up. Fortunately, it looks like that @developernotes already committed a fix: bdf9fa7#diff-fa99240cf3130ab4b9d25c14923ee2d6

Hi @mittt

As @commonsguy mentioned, that has already been fixed in master. This fix will be included in our next public release. Thanks.