Summary: This models all the Create and Copy functions from CoreGraphics, examples in the tests. These functions all allocate memory that needs to be manually released. The modelling of the release functions will happen in a following diff. Until then, we have some false positives in the tests. This check is currently in biabduction, and we aim to move it to Pulse. Reviewed By: jvillard Differential Revision: D20626395 fbshipit-source-id: b39eae2d9master
parent
1e25cf2168
commit
6f2b52fcc7
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MemoryLeaks
|
||||
|
||||
@property(strong) UIView* backgroundCoveringView;
|
||||
@property(strong) UIView* attachmentContainerView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MemoryLeaks
|
||||
|
||||
- (void)cg_path_create_with_rect_no_leak_good_FP {
|
||||
UIView* attachmentContainerView = [UIView alloc];
|
||||
CGPathRef shadowPath =
|
||||
CGPathCreateWithRect(attachmentContainerView.bounds, NULL);
|
||||
CGPathRelease(shadowPath);
|
||||
}
|
||||
|
||||
- (void)cg_path_create_with_rect_leak_bad {
|
||||
CGPathRef shadowPath =
|
||||
CGPathCreateWithRect(self.backgroundCoveringView.bounds, NULL);
|
||||
self.backgroundCoveringView.layer.shadowPath = shadowPath;
|
||||
}
|
||||
|
||||
+ (void)cg_path_create_mutable_leak_bad:(CGRect)rect {
|
||||
0.20f * CGRectGetHeight(rect);
|
||||
CGPathCreateMutable();
|
||||
}
|
||||
|
||||
+ (void)cg_path_create_mutable_no_leak_good_FP:(CGRect)rect {
|
||||
CGFloat lineThickness = 0.20f * CGRectGetHeight(rect);
|
||||
// One rectangle
|
||||
CGMutablePathRef path1 = CGPathCreateMutable();
|
||||
CFRelease(path1);
|
||||
}
|
||||
|
||||
+ (void)cg_bitmap_context_create_image_no_leak_good_FP {
|
||||
CGImageRef newImage = CGBitmapContextCreateImage(nil);
|
||||
CGImageRelease(newImage);
|
||||
}
|
||||
|
||||
@end
|
@ -1,2 +1,7 @@
|
||||
codetoanalyze/objc/pulse/MemoryLeaks.m, MemoryLeaks::cg_bitmap_context_create_image_no_leak_good_FP, 2, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here,memory becomes unreachable here]
|
||||
codetoanalyze/objc/pulse/MemoryLeaks.m, MemoryLeaks::cg_path_create_mutable_leak_bad:, 2, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here,memory becomes unreachable here]
|
||||
codetoanalyze/objc/pulse/MemoryLeaks.m, MemoryLeaks::cg_path_create_mutable_no_leak_good_FP:, 4, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here,memory becomes unreachable here]
|
||||
codetoanalyze/objc/pulse/MemoryLeaks.m, MemoryLeaks::cg_path_create_with_rect_leak_bad, 3, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here,memory becomes unreachable here]
|
||||
codetoanalyze/objc/pulse/MemoryLeaks.m, MemoryLeaks::cg_path_create_with_rect_no_leak_good_FP, 4, PULSE_MEMORY_LEAK, no_bucket, ERROR, [allocation part of the trace starts here,allocation occurs here,memory becomes unreachable here]
|
||||
codetoanalyze/objc/pulse/use_after_free.m, PulseTest::use_after_free_simple_in_objc_method_bad:, 2, USE_AFTER_FREE, no_bucket, ERROR, [invalidation part of the trace starts here,parameter `x` of PulseTest::use_after_free_simple_in_objc_method_bad:,was invalidated by call to `free()`,use-after-lifetime part of the trace starts here,parameter `x` of PulseTest::use_after_free_simple_in_objc_method_bad:,invalid access occurs here]
|
||||
codetoanalyze/objc/pulse/use_after_free.m, use_after_free_simple_bad, 2, USE_AFTER_FREE, no_bucket, ERROR, [invalidation part of the trace starts here,parameter `x` of use_after_free_simple_bad,was invalidated by call to `free()`,use-after-lifetime part of the trace starts here,parameter `x` of use_after_free_simple_bad,invalid access occurs here]
|
||||
|
Loading…
Reference in new issue