~tcurdt/sparkle/devel

« back to all changes in this revision

Viewing changes to SUUserDefaults.m

  • Committer: Andy Matuschak
  • Date: 2008-07-03 06:31:20 UTC
  • Revision ID: andy@andymatuschak.org-20080703063120-ikmmtv2ri6p1mm34
Fixes 244692:

Sparkle crashes on Tiger due to a double-release in SUUserDefaults.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
{
45
45
        [self verifyIdentifier];
46
46
        CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)identifier);
47
 
        // Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistratioDomain, so anything
 
47
        // Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything
48
48
        // passed into -[NSUserDefaults registerDefaults:] is ignored.  The following line falls
49
49
        // back to using NSUserDefaults, but only if the host bundle is the main bundle, and no value
50
50
        // is found elsewhere.
51
51
        if (obj == NULL && [identifier isEqualToString:[[NSBundle mainBundle] bundleIdentifier]])
52
52
                obj = [[NSUserDefaults standardUserDefaults] objectForKey:defaultName];
53
 
#if MAC_OS_X_VERSION_MIN_REQUIRED > 1050
54
 
        return [NSMakeCollectable(obj) autorelease];
55
 
#else
56
 
        return [(id)obj autorelease];
 
53
        id result = nil;
 
54
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
 
55
        result = [NSMakeCollectable(obj) autorelease];
57
56
#endif  
 
57
        return result ?: (id)obj;
58
58
}
59
59
 
60
60
- (void)setObject:(id)value forKey:(NSString *)defaultName;