Clear statement before closing db in cookie code.
sql::Statement maintains a weak ref to the associated sql::Connection,
meaning that if the database and statement are destructed in the wrong
order, a use-after-free can result. sql::Statement::Clear() allows
resetting the statement to the default-constructed state.
BUG=111376
TEST=fewer crashes.
Review URL: http://codereview.chromium.org/9418021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122430 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/sql/statement.h b/sql/statement.h
index fb70cf1..5b4ff92c 100644
--- a/sql/statement.h
+++ b/sql/statement.h
@@ -55,6 +55,10 @@
// be valid. Use is_valid() to check if it's OK.
void Assign(scoped_refptr<Connection::StatementRef> ref);
+ // Resets the statement to an uninitialized state corrosponding to
+ // the default constructor, releasing the StatementRef.
+ void Clear();
+
// Returns true if the statement can be executed. All functions can still
// be used if the statement is invalid, but they will return failure or some
// default value. This is because the statement can become invalid in the