Bug 994344 - Prevent access of null mDB in seer. r=mcmanus, a=sledru
authorNicholas Hurley <hurley@todesschaf.org>
Fri, 11 Apr 2014 22:52:58 -0400
changeset 183766 e24aafe4dffd
parent 183765 55422890fb8f
child 183767 c8f1a4f5ca4d
push id3476
push userryanvm@gmail.com
push date2014-04-15 17:26 +0000
treeherdermozilla-beta@c8f1a4f5ca4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, sledru
bugs994344
milestone29.0
Bug 994344 - Prevent access of null mDB in seer. r=mcmanus, a=sledru
netwerk/base/src/Seer.cpp
--- a/netwerk/base/src/Seer.cpp
+++ b/netwerk/base/src/Seer.cpp
@@ -2315,26 +2315,32 @@ public:
 };
 
 // Returns the current size (in bytes) of the db file on disk
 int64_t
 Seer::GetDBFileSize()
 {
   MOZ_ASSERT(!NS_IsMainThread(), "GetDBFileSize called on main thread!");
 
+  nsresult rv = EnsureInitStorage();
+  if (NS_FAILED(rv)) {
+    SEER_LOG(("GetDBFileSize called without db available!"));
+    return 0;
+  }
+
   CommitTransaction();
 
   nsCOMPtr<mozIStorageStatement> countStmt = mStatements.GetCachedStatement(
       NS_LITERAL_CSTRING("PRAGMA page_count;"));
   if (!countStmt) {
     return 0;
   }
   mozStorageStatementScoper scopedCount(countStmt);
   bool hasRows;
-  nsresult rv = countStmt->ExecuteStep(&hasRows);
+  rv = countStmt->ExecuteStep(&hasRows);
   if (NS_FAILED(rv) || !hasRows) {
     return 0;
   }
   int64_t pageCount;
   rv = countStmt->GetInt64(0, &pageCount);
   if (NS_FAILED(rv)) {
     return 0;
   }