summaryrefslogtreecommitdiff
path: root/MobileCydia.mm
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2015-07-04 16:55:26 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2015-07-04 16:55:26 -0700
commit9adfb865fde8fc0e7b93962e57e3922a66fd180d (patch)
treec89b08eb95f977600f51e8f42f2e14352839bb1e /MobileCydia.mm
parent14de2b3aa9bdbce41d2f2c7031b2f024f62d8814 (diff)
Take _deep_ mutable copies of CFPreference values.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r--MobileCydia.mm17
1 files changed, 13 insertions, 4 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 5528311..1127bb0 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -10034,6 +10034,16 @@ MSHook(id, NSUserDefaults$objectForKey$, NSUserDefaults *self, SEL _cmd, NSStrin
return _NSUserDefaults$objectForKey$(self, _cmd, key);
}
+static NSMutableDictionary *AutoreleaseDeepMutableCopyOfDictionary(CFTypeRef type) {
+ if (type == NULL)
+ return nil;
+ if (CFGetTypeID(type) != CFDictionaryGetTypeID())
+ return nil;
+ CFTypeRef copy(CFPropertyListCreateDeepCopy(kCFAllocatorDefault, type, kCFPropertyListMutableContainers));
+ CFRelease(type);
+ return [(NSMutableDictionary *) copy autorelease];
+}
+
int main(int argc, char *argv[]) {
int fd(open("/tmp/cydia.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
dup2(fd, 2);
@@ -10288,10 +10298,9 @@ int main(int argc, char *argv[]) {
MetaFile_.Open("/var/mobile/Library/Cydia/metadata.cb0");
_trace();
- // XXX: port this to NSUserDefaults when you aren't in such a rush
- Values_ = [[[(NSDictionary *) CFPreferencesCopyAppValue(CFSTR("CydiaValues"), CFSTR("com.saurik.Cydia")) autorelease] mutableCopy] autorelease];
- Sections_ = [[[(NSDictionary *) CFPreferencesCopyAppValue(CFSTR("CydiaSections"), CFSTR("com.saurik.Cydia")) autorelease] mutableCopy] autorelease];
- Sources_ = [[[(NSDictionary *) CFPreferencesCopyAppValue(CFSTR("CydiaSources"), CFSTR("com.saurik.Cydia")) autorelease] mutableCopy] autorelease];
+ Values_ = AutoreleaseDeepMutableCopyOfDictionary(CFPreferencesCopyAppValue(CFSTR("CydiaValues"), CFSTR("com.saurik.Cydia")));
+ Sections_ = AutoreleaseDeepMutableCopyOfDictionary(CFPreferencesCopyAppValue(CFSTR("CydiaSections"), CFSTR("com.saurik.Cydia")));
+ Sources_ = AutoreleaseDeepMutableCopyOfDictionary(CFPreferencesCopyAppValue(CFSTR("CydiaSources"), CFSTR("com.saurik.Cydia")));
Version_ = [(NSNumber *) CFPreferencesCopyAppValue(CFSTR("CydiaVersion"), CFSTR("com.saurik.Cydia")) autorelease];
_trace();