From b4c363bad50f8f5733c7b10c232fb164ecc708b5 Mon Sep 17 00:00:00 2001 From: "glotov@chromium.org" Date: Thu, 17 Jan 2013 13:11:17 +0000 Subject: Fixing null pointer dereference. BUG=chromium:158178 TEST=units,make sure such SEGV doesnt happen on x86-generic-bot (where it pops periodically now) Review URL: https://chromiumcodereview.appspot.com/11886065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177399 0039d316-1c4b-4281-b951-d872f2087c98 --- sql/connection.h | 5 +++-- sql/statement.cc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'sql') diff --git a/sql/connection.h b/sql/connection.h index b9f45ec..2722ffd 100644 --- a/sql/connection.h +++ b/sql/connection.h @@ -370,8 +370,9 @@ class SQL_EXPORT Connection { // When true, the statement can be used. bool is_valid() const { return !!stmt_; } - // If we've not been linked to a connection, this will be NULL. Guaranteed - // non-NULL when is_valid(). + // If we've not been linked to a connection, this will be NULL. + // TODO(shess): connection_ can be NULL in case of GetUntrackedStatement(), + // which prevents Statement::OnError() from forwarding errors. Connection* connection() const { return connection_; } // Returns the sqlite statement if any. If the statement is not active, diff --git a/sql/statement.cc b/sql/statement.cc index 84dfd2e..cd55bf7 100644 --- a/sql/statement.cc +++ b/sql/statement.cc @@ -306,7 +306,7 @@ bool Statement::CheckOk(int err) const { int Statement::CheckError(int err) { // Please don't add DCHECKs here, OnSqliteError() already has them. succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); - if (!succeeded_ && is_valid()) + if (!succeeded_ && is_valid() && ref_->connection()) return ref_->connection()->OnSqliteError(err, this); return err; } -- cgit v1.1