Bug 1221449: Add null ptr check and fix variable shadowing in OSXNotificationCenter.mm. r=spohl
authorJosh Aas <joshmoz@fastmail.com>
Sat, 07 Nov 2015 18:23:00 +0900
changeset 271634 c4dd82aa903d89b3835ceb38cf0341a4190c383e
parent 271633 8707d23c0be0d0a571f8c12c83a6a54be1f74293
child 271635 da2deb62849ed39ee79bb25862c7a50968221828
push id67720
push userjosh@mozilla.com
push dateSat, 07 Nov 2015 09:23:10 +0000
treeherdermozilla-inbound@c4dd82aa903d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1221449
milestone45.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 1221449: Add null ptr check and fix variable shadowing in OSXNotificationCenter.mm. r=spohl
widget/cocoa/OSXNotificationCenter.mm
--- a/widget/cocoa/OSXNotificationCenter.mm
+++ b/widget/cocoa/OSXNotificationCenter.mm
@@ -242,35 +242,35 @@ OSXNotificationCenter::ShowAlertNotifica
   Class unClass = NSClassFromString(@"NSUserNotification");
   id<FakeNSUserNotification> notification = [[unClass alloc] init];
   notification.title = nsCocoaUtils::ToNSString(aAlertTitle);
 
   nsAutoString hostPort;
   nsAlertsUtils::GetSourceHostPort(aPrincipal, hostPort);
   nsCOMPtr<nsIStringBundle> bundle;
   nsCOMPtr<nsIStringBundleService> sbs = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-  nsresult rv = sbs->CreateBundle("chrome://alerts/locale/alert.properties", getter_AddRefs(bundle));
+  sbs->CreateBundle("chrome://alerts/locale/alert.properties", getter_AddRefs(bundle));
 
-  if (!hostPort.IsEmpty()) {
+  if (!hostPort.IsEmpty() && bundle) {
     const char16_t* formatStrings[] = { hostPort.get() };
     nsXPIDLString notificationSource;
     bundle->FormatStringFromName(MOZ_UTF16("source.label"),
                                  formatStrings,
                                  ArrayLength(formatStrings),
                                  getter_Copies(notificationSource));
     notification.subtitle = nsCocoaUtils::ToNSString(notificationSource);
   }
 
   notification.informativeText = nsCocoaUtils::ToNSString(aAlertText);
   notification.soundName = NSUserNotificationDefaultSoundName;
   notification.hasActionButton = NO;
 
   // If this is not an application/extension alert, show additional actions dealing with permissions.
   if (nsAlertsUtils::IsActionablePrincipal(aPrincipal)) {
-    if (NS_SUCCEEDED(rv)) {
+    if (bundle) {
       nsXPIDLString closeButtonTitle, actionButtonTitle, disableButtonTitle, settingsButtonTitle;
       bundle->GetStringFromName(MOZ_UTF16("closeButton.title"),
                                 getter_Copies(closeButtonTitle));
       bundle->GetStringFromName(MOZ_UTF16("actionButton.label"),
                                 getter_Copies(actionButtonTitle));
       if (!hostPort.IsEmpty()) {
         const char16_t* formatStrings[] = { hostPort.get() };
         bundle->FormatStringFromName(MOZ_UTF16("webActions.disableForOrigin.label"),