Skip to content

Commit

Permalink
Plug leak in _createDockMenu:
Browse files Browse the repository at this point in the history
  • Loading branch information
jslegendre committed Nov 5, 2020
1 parent 1539270 commit 9c3eddd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions AfloatX/AfloatX.m
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,17 @@ - (CFArrayRef)_createDockMenu:(BOOL)enabled {
[invertColorItem setState:NSControlStateValueOff];
}

CFMutableArrayRef finalMenu = CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks);

CFArrayRef flatDockMenu = ZKOrig(CFArrayRef, enabled);
CFArrayAppendArray(finalMenu, flatDockMenu, CFRangeMake(0, CFArrayGetCount(flatDockMenu)));
CFRelease(flatDockMenu);

CFArrayRef flatAfloatXMenu = (__bridge CFArrayRef)(objc_msgSend(self, sel_getUid("_flattenMenu:flatList:"), AfloatXMenu, nil));

NSMutableArray *combinedFlatMenus = (__bridge NSMutableArray *)flatDockMenu;
[combinedFlatMenus addObjectsFromArray:(__bridge NSArray *)flatAfloatXMenu];
return (__bridge CFArrayRef)combinedFlatMenus;
CFArrayAppendArray(finalMenu, flatAfloatXMenu, CFRangeMake(0, CFArrayGetCount(flatAfloatXMenu)));
CFRelease(flatAfloatXMenu);

return finalMenu;
}
@end

0 comments on commit 9c3eddd

Please sign in to comment.