OSDN Git Service

Throw clear error if a row doesn't fit into CursorWindow
authorFyodor Kupolov <fkupolov@google.com>
Wed, 18 Oct 2017 22:03:21 +0000 (15:03 -0700)
committerFyodor Kupolov <fkupolov@google.com>
Sat, 21 Oct 2017 01:09:48 +0000 (18:09 -0700)
Test: android.database.sqlite.cts.SQLiteCursorTest
Bug: 66946862
Change-Id: I0b3c7c8c0a4aac2f4b024c579b482cebe79231c0

core/jni/android_database_SQLiteConnection.cpp

index c3f9bf7..1efff7f 100644 (file)
@@ -765,6 +765,14 @@ static jlong nativeExecuteForCursorWindow(JNIEnv* env, jclass clazz,
     if (startPos > totalRows) {
         ALOGE("startPos %d > actual rows %d", startPos, totalRows);
     }
+    if (totalRows > 0 && addedRows == 0) {
+        String8 msg;
+        msg.appendFormat("Row too big to fit into CursorWindow requiredPos=%d, totalRows=%d",
+                requiredPos, totalRows);
+        throw_sqlite3_exception(env, SQLITE_TOOBIG, NULL, msg.string());
+        return 0;
+    }
+
     jlong result = jlong(startPos) << 32 | jlong(totalRows);
     return result;
 }