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 192839 3be2814c689703675df858414dde8ee635eec028
parent 192838 668a99c8678e3534858f4eb2fda8f0a6adf2056a
child 192840 2cdcd7e28256405bb7fd5a8020e69ce1b08fbfe7
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, sledru
bugs994344
milestone30.0a2
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;
   }