Skip to content

Commit 8962abd

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Check whether db was really opened read/write."
2 parents 3c6ac8c + 330ec91 commit 8962abd

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)