Skip to content

Commit b267948

Browse files
author
Jeff Brown
committed
Fix potential NPE in SQLiteProgram.
Bug: 6122537 Change-Id: I76a12f58f08b708065dfdd11c78f54701d90873b
1 parent 8ac70c4 commit b267948

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

core/java/android/database/sqlite/SQLiteProgram.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,20 @@ public abstract class SQLiteProgram extends SQLiteClosable {
6464
break;
6565
}
6666

67+
if (bindArgs != null && bindArgs.length > mNumParameters) {
68+
throw new IllegalArgumentException("Too many bind arguments. "
69+
+ bindArgs.length + " arguments were provided but the statement needs "
70+
+ mNumParameters + " arguments.");
71+
}
72+
6773
if (mNumParameters != 0) {
6874
mBindArgs = new Object[mNumParameters];
75+
if (bindArgs != null) {
76+
System.arraycopy(bindArgs, 0, mBindArgs, 0, bindArgs.length);
77+
}
6978
} else {
7079
mBindArgs = null;
7180
}
72-
73-
if (bindArgs != null) {
74-
if (bindArgs.length > mNumParameters) {
75-
throw new IllegalArgumentException("Too many bind arguments. "
76-
+ bindArgs.length + " arguments were provided but the statement needs "
77-
+ mNumParameters + " arguments.");
78-
}
79-
System.arraycopy(bindArgs, 0, mBindArgs, 0, bindArgs.length);
80-
}
8181
}
8282

8383
final SQLiteDatabase getDatabase() {

0 commit comments

Comments
 (0)