From 9d4be0bd01696768602a313f627a802b358b5885 Mon Sep 17 00:00:00 2001 From: Marcio Barbosa Date: Fri, 11 Nov 2016 13:21:58 -0800 Subject: [PATCH] macos: do not quit prefpane unexpectedly If the user opens the OpenAFS preference pane and choose the Mounts tab, the preference pane crashes. To fix the problem, do not assume that we can cast a NSdictionary object to NSMutableDictionary. Change-Id: I3b5f6cb324a6b53c6b53606f71185f61450ee793 Reviewed-on: https://gerrit.openafs.org/12446 Reviewed-by: Benjamin Kaduk Tested-by: Benjamin Kaduk --- .../AFSPreference/AFSBackgrounder/AFSBackgrounderDelegate.m | 9 +++++---- src/platform/DARWIN/AFSPreference/AFSCommanderPref.m | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/platform/DARWIN/AFSPreference/AFSBackgrounder/AFSBackgrounderDelegate.m b/src/platform/DARWIN/AFSPreference/AFSBackgrounder/AFSBackgrounderDelegate.m index d2d81fa..b636de9 100644 --- a/src/platform/DARWIN/AFSPreference/AFSBackgrounder/AFSBackgrounderDelegate.m +++ b/src/platform/DARWIN/AFSPreference/AFSBackgrounder/AFSBackgrounderDelegate.m @@ -166,10 +166,11 @@ //get link configuration NSData *prefData = (NSData*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_LINK_CONFIGURATION, (CFStringRef)kAfsCommanderID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - linkConfiguration = (NSMutableDictionary*)[NSPropertyListSerialization propertyListFromData:prefData - mutabilityOption:NSPropertyListMutableContainers - format:nil - errorDescription:nil]; + NSDictionary *linkDict = (NSMutableDictionary*)[NSPropertyListSerialization propertyListFromData:prefData + mutabilityOption:NSPropertyListMutableContainers + format:nil + errorDescription:nil]; + linkConfiguration = [linkDict mutableCopy]; //get link enabled status NSNumber *linkEnabledStatus = (NSNumber*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_USE_LINK, (CFStringRef)kAfsCommanderID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); diff --git a/src/platform/DARWIN/AFSPreference/AFSCommanderPref.m b/src/platform/DARWIN/AFSPreference/AFSCommanderPref.m index dd6d9bf..1a06b02 100644 --- a/src/platform/DARWIN/AFSPreference/AFSCommanderPref.m +++ b/src/platform/DARWIN/AFSPreference/AFSCommanderPref.m @@ -332,10 +332,11 @@ //link configuration NSData *prefData = (NSData*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_LINK_CONFIGURATION, (CFStringRef)kAfsCommanderID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - linkConfiguration = (NSMutableDictionary*)[NSPropertyListSerialization propertyListFromData:prefData - mutabilityOption:NSPropertyListMutableContainers - format:nil - errorDescription:nil]; + NSDictionary *linkDict = (NSMutableDictionary*)[NSPropertyListSerialization propertyListFromData:prefData + mutabilityOption:NSPropertyListMutableContainers + format:nil + errorDescription:nil]; + linkConfiguration = [linkDict mutableCopy]; } // ------------------------------------------------------------------------------- -- 1.9.4