Skip to content

Commit 330ec91

Browse files
author
Jeff Brown
committed
Check whether db was really opened read/write.
Bug: 6176510 Change-Id: I7aeeb4340e55d554a57bb46c3c27ab37186f7e3a
1 parent 59a422e commit 330ec91

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/jni/android_database_SQLiteConnection.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ static jint nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFlag
120120
return 0;
121121
}
122122

123+
// Check that the database is really read/write when that is what we asked for.
124+
if ((sqliteFlags & SQLITE_OPEN_READWRITE) && sqlite3_db_readonly(db, NULL)) {
125+
throw_sqlite3_exception(env, db, "Could not open the database in read/write mode.");
126+
sqlite3_close(db);
127+
return 0;
128+
}
129+
123130
// Set the default busy handler to retry for 1000ms and then return SQLITE_BUSY
124131
err = sqlite3_busy_timeout(db, 1000 /* ms */);
125132
if (err != SQLITE_OK) {

0 commit comments

Comments
 (0)