Bug 814554 - Don't stop reading the permissions database when an invalid entry is found. r=sicking
authorMounir Lamouri <mounir.lamouri@gmail.com>
Tue, 27 Nov 2012 23:29:19 +0000
changeset 114307 af301a7b9ecfe3848ce42b174e1de709e5fcdd7a
parent 114306 30cd23db6461c339cdab91ed5321214c5d825f25
child 114308 ae5e741238ccf7679ad78411dbe183b53af51523
push id23913
push useremorley@mozilla.com
push dateWed, 28 Nov 2012 17:11:31 +0000
treeherdermozilla-central@17c267a881cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs814554
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 814554 - Don't stop reading the permissions database when an invalid entry is found. r=sicking
extensions/cookie/nsPermissionManager.cpp
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -1311,46 +1311,65 @@ nsPermissionManager::Read()
   int64_t id;
   nsAutoCString host, type;
   uint32_t permission;
   uint32_t expireType;
   int64_t expireTime;
   uint32_t appId;
   bool isInBrowserElement;
   bool hasResult;
+  bool readError = false;
+
   while (NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && hasResult) {
     // explicitly set our entry id counter for use in AddInternal(),
     // and keep track of the largest id so we know where to pick up.
     id = stmt->AsInt64(0);
     if (id > mLargestID)
       mLargestID = id;
 
     rv = stmt->GetUTF8String(1, host);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (NS_FAILED(rv)) {
+      readError = true;
+      continue;
+    }
 
     rv = stmt->GetUTF8String(2, type);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (NS_FAILED(rv)) {
+      readError = true;
+      continue;
+    }
 
     permission = stmt->AsInt32(3);
     expireType = stmt->AsInt32(4);
 
     // convert into int64_t value (milliseconds)
     expireTime = stmt->AsInt64(5);
 
     MOZ_ASSERT(stmt->AsInt64(6) >= 0);
     appId = static_cast<uint32_t>(stmt->AsInt64(6));
     isInBrowserElement = static_cast<bool>(stmt->AsInt32(7));
 
     nsCOMPtr<nsIPrincipal> principal;
     nsresult rv = GetPrincipal(host, appId, isInBrowserElement, getter_AddRefs(principal));
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (NS_FAILED(rv)) {
+      readError = true;
+      continue;
+    }
 
     rv = AddInternal(principal, type, permission, id, expireType, expireTime,
                      eDontNotify, eNoDBOperation);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (NS_FAILED(rv)) {
+      readError = true;
+      continue;
+    }
+  }
+
+  if (readError) {
+    NS_ERROR("Error occured while reading the permissions database!");
+    return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 static const char kMatchTypeHost[] = "host";
 
 nsresult