Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: sql/recovery.cc

Issue 1657593005: [sql] Prevent recovery against a closed database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Detect API mis-use. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sql/recovery.cc
diff --git a/sql/recovery.cc b/sql/recovery.cc
index 377aafbf1fbeb71f98d8ee82835f323f2327a282..5e101b1ce3b456d534734cec0c412b527b3153d9 100644
--- a/sql/recovery.cc
+++ b/sql/recovery.cc
@@ -108,6 +108,16 @@ bool Recovery::FullRecoverySupported() {
scoped_ptr<Recovery> Recovery::Begin(
Connection* connection,
const base::FilePath& db_path) {
+ // Recovery is likely to be used in error handling. Since recovery changes
+ // the state of the handle, protect against multiple layers attempting the
+ // same recovery.
+ if (!connection->is_open()) {
+ // Warn about API mis-use.
+ DLOG_IF(FATAL, !connection->poisoned_)
+ << "Illegal to recover with closed database";
+ return scoped_ptr<Recovery>();
+ }
+
scoped_ptr<Recovery> r(new Recovery(connection));
if (!r->Init(db_path)) {
// TODO(shess): Should Init() failure result in Raze()?
« no previous file with comments | « sql/connection.cc ('k') | sql/recovery_unittest.cc » ('j') | sql/recovery_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698