sqlcipher / android-database-sqlcipher

Android SQLite API based on SQLCipher
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
Other
2.76k stars 568 forks source link

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

Closed mittt closed 4 years ago

mittt commented 4 years ago

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

commonsguy commented 4 years ago

My fault! I apologize for messing that up. Fortunately, it looks like that @developernotes already committed a fix: https://github.com/sqlcipher/android-database-sqlcipher/commit/bdf9fa71e8bdd3ee62dbdd2dcecf536abf4bb6cd#diff-fa99240cf3130ab4b9d25c14923ee2d6

developernotes commented 4 years ago

Hi @mittt

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