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 <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Marcio Barbosa 2016-11-11 13:21:58 -08:00 committed by Benjamin Kaduk
parent 3e8529b6ef
commit 9d4be0bd01
2 changed files with 10 additions and 8 deletions

View File

@ -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);

View File

@ -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];
}
// -------------------------------------------------------------------------------