Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1437c7e7 authored by Brett Chabot's avatar Brett Chabot
Browse files

Add null checks in CursorWindow#put{String,Blob}.

Currently passing null values to putString or putBlob will
crash in native code, which is not a great developer experience.

This commit adds null checks so the java layer will throw NPEs.

Flag: EXEMPT bugfix
Test: atest android.database.CursorWindow
Bug: 351839899
Change-Id: Ic4f1c55d0edb56fa08fabf4be6193afb6e86c3e6
parent b283f3d3
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.database;

import static java.util.Objects.requireNonNull;

import android.annotation.BytesLong;
import android.annotation.IntRange;
import android.compat.annotation.UnsupportedAppUsage;
@@ -640,6 +642,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
     */
    public boolean putBlob(byte[] value,
            @IntRange(from = 0) int row, @IntRange(from = 0) int column) {
        requireNonNull(value);
        acquireReference();
        try {
            return nativePutBlob(mWindowPtr, value, row - mStartPos, column);
@@ -658,6 +661,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
     */
    public boolean putString(String value,
            @IntRange(from = 0) int row, @IntRange(from = 0) int column) {
        requireNonNull(value);
        acquireReference();
        try {
            return nativePutString(mWindowPtr, value, row - mStartPos, column);