Bug 1523904 - Return NS_ERROR_FAILURE when setting UID on a read-only address book. r=mkmelin,BenB a=jorgk
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 08 Feb 2019 15:08:08 +1300
changeset 33471 7759b93fc8dd
parent 33470 9378f2d586b0
child 33472 96ed115c265a
push id2371
push usermozilla@jorgk.com
push dateFri, 08 Feb 2019 10:35:50 +0000
treeherdercomm-beta@86cb9d0c8982 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, BenB, jorgk
bugs1523904
Bug 1523904 - Return NS_ERROR_FAILURE when setting UID on a read-only address book. r=mkmelin,BenB a=jorgk
mailnews/addrbook/src/nsAbCardProperty.cpp
--- a/mailnews/addrbook/src/nsAbCardProperty.cpp
+++ b/mailnews/addrbook/src/nsAbCardProperty.cpp
@@ -381,17 +381,28 @@ NS_IMETHODIMP nsAbCardProperty::SetUID(c
 
   nsCOMPtr<nsIAbManager> abManager = do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr <nsIAbDirectory> directory = nullptr;
   rv = abManager->GetDirectoryFromId(directoryId, getter_AddRefs(directory));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  return directory ? directory->ModifyCard(this) : NS_OK;
+  if (!directory) {
+    return NS_OK;
+  }
+
+  bool readOnly;
+  rv = directory->GetReadOnly(&readOnly);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  if (readOnly) {
+    return NS_ERROR_FAILURE;
+  }
+  return directory->ModifyCard(this);
 }
 
 NS_IMETHODIMP nsAbCardProperty::GetFirstName(nsAString &aString)
 {
   nsresult rv = GetPropertyAsAString(kFirstNameProperty, aString);
   if (rv == NS_ERROR_NOT_AVAILABLE)
   {
     aString.Truncate();