diff options
-rw-r--r-- | chromium/components/history/core/browser/history_backend.cc | 9 | ||||
-rw-r--r-- | chromium/components/history/core/browser/history_database.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/chromium/components/history/core/browser/history_backend.cc b/chromium/components/history/core/browser/history_backend.cc index ab9df06777a..6470d31cb1c 100644 --- a/chromium/components/history/core/browser/history_backend.cc +++ b/chromium/components/history/core/browser/history_backend.cc @@ -276,6 +276,15 @@ HistoryBackend::~HistoryBackend() { // Release stashed embedder object before cleaning up the databases. supports_user_data_helper_.reset(); + // Clear the error callback. The error callback that is installed does not + // process an error immediately, rather it uses a PostTask() with `this`. As + // `this` is being deleted, scheduling a PostTask() with `this` would be + // fatal (use-after-free). Additionally, as we're in shutdown, there isn't + // much point in trying to handle the error. If the error is really fatal, + // we'll cleanup the next time the backend is created. + if (db_) + db_->reset_error_callback(); + // First close the databases before optionally running the "destroy" task. CloseAllDatabases(); diff --git a/chromium/components/history/core/browser/history_database.h b/chromium/components/history/core/browser/history_database.h index 841da9e21aa..fe4ccb0975d 100644 --- a/chromium/components/history/core/browser/history_database.h +++ b/chromium/components/history/core/browser/history_database.h @@ -81,6 +81,7 @@ class HistoryDatabase : public DownloadDatabase, void set_error_callback(const sql::Database::ErrorCallback& error_callback) { db_.set_error_callback(error_callback); } + void reset_error_callback() { db_.reset_error_callback(); } // Must call this function to complete initialization. Will return // sql::INIT_OK on success. Otherwise, no other function should be called. You |