Skip to content

Commit

Permalink
Merge pull request #25 from 166MMX/crash-fixes
Browse files Browse the repository at this point in the history
Crash fixes
  • Loading branch information
ElDeveloper authored Oct 14, 2016
2 parents 8d807af + e750d71 commit 4932376
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 10 additions & 8 deletions MFCore/MFCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@
BOOL mfcGetStateOfLoginItemWithPath(NSString *path) {
UInt32 seedValue;
LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
NSArray *loginItems = (__bridge NSArray *)(LSSharedFileListCopySnapshot(loginItemsRef, &seedValue));
CFArrayRef loginItems = LSSharedFileListCopySnapshot(loginItemsRef, &seedValue);
BOOL present = FALSE;
for(id loginItem in loginItems) {
CFIndex arrayCount = CFArrayGetCount(loginItems);
for(CFIndex i = 0; i < arrayCount; ++i) {
CFURLRef urlRef;
LSSharedFileListItemRef itemRef = (__bridge LSSharedFileListItemRef)loginItem;
LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(loginItems, i);
LSSharedFileListItemResolve(itemRef, 0, &urlRef, NULL);
NSURL *theURL = (__bridge NSURL*) urlRef;
present = [[theURL path] isEqualToString:path];
Expand All @@ -86,7 +87,7 @@ BOOL mfcGetStateOfLoginItemWithPath(NSString *path) {
}
}
CFRelease(loginItemsRef);
CFRelease((__bridge CFTypeRef)(loginItems));
CFRelease(loginItems);
return present;
}

Expand All @@ -103,10 +104,11 @@ BOOL mfcSetStateForAgentLoginItem(BOOL state) {

UInt32 seedValue;
LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
NSArray *loginItems = (__bridge NSArray *)LSSharedFileListCopySnapshot(loginItemsRef, &seedValue);
for(id loginItem in loginItems) {
CFArrayRef loginItems = LSSharedFileListCopySnapshot(loginItemsRef, &seedValue);
CFIndex arrayCount = CFArrayGetCount(loginItems);
for(CFIndex i = 0; i < arrayCount; ++i) {
CFURLRef urlRef;
LSSharedFileListItemRef itemRef = (__bridge LSSharedFileListItemRef)loginItem;
LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(loginItems, i);
LSSharedFileListItemResolve(itemRef, 0, &urlRef, NULL);
NSURL *theURL = (__bridge NSURL*) urlRef;
NSString* checkPath = [[theURL path] lastPathComponent];
Expand All @@ -121,7 +123,7 @@ BOOL mfcSetStateForAgentLoginItem(BOOL state) {
(__bridge CFURLRef)[NSURL fileURLWithPath: agentPath], NULL, NULL);
}
CFRelease(loginItemsRef);
CFRelease((__bridge CFTypeRef)(loginItems));
CFRelease(loginItems);
return YES;
}

Expand Down
3 changes: 2 additions & 1 deletion MFCore/MFFilesystemController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ @implementation MFFilesystemController
#pragma mark Init and Singleton methods
+ (MFFilesystemController *)sharedController {
if (sharedController == nil) {
sharedController = [[self alloc] init];
sharedController = [self alloc];
[sharedController init];
}

return sharedController;
Expand Down

0 comments on commit 4932376

Please sign in to comment.