diff --git a/infer/models/objc/src/CoreVideo.c b/infer/models/objc/src/CoreVideo.c new file mode 100644 index 000000000..39260e94a --- /dev/null +++ b/infer/models/objc/src/CoreVideo.c @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +#import +#import + +void CVPixelBufferRelease(CVPixelBufferRef pxbuffer) { __free_cf(pxbuffer); } diff --git a/infer/tests/codetoanalyze/objc/errors/Makefile b/infer/tests/codetoanalyze/objc/errors/Makefile index 19a53dee9..3395e781b 100644 --- a/infer/tests/codetoanalyze/objc/errors/Makefile +++ b/infer/tests/codetoanalyze/objc/errors/Makefile @@ -27,6 +27,7 @@ SOURCES_DEFAULT = \ memory_leaks_benchmark/NSString_models_tests.m \ memory_leaks_benchmark/NSData_models_tests.m \ memory_leaks_benchmark/RetainReleaseExampleBucketing.m \ + memory_leaks_benchmark/CoreVideoExample.m \ npe/Fraction.m \ npe/NPD_core_foundation.m \ npe/Npe_with_equal_names.m \ diff --git a/infer/tests/codetoanalyze/objc/errors/issues.exp b/infer/tests/codetoanalyze/objc/errors/issues.exp index d46bb50bc..7502090c4 100644 --- a/infer/tests/codetoanalyze/objc/errors/issues.exp +++ b/infer/tests/codetoanalyze/objc/errors/issues.exp @@ -73,6 +73,7 @@ codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZer codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZero2, 2, DIVIDE_BY_ZERO, [start of procedure shouldThrowDivideByZero2(),start of procedure init,return from a call to Base_init,start of procedure returnsZero2(),Condition is false,return from a call to returnsZero2] codetoanalyze/objc/errors/subtyping/KindOfClassExample.m, shouldThrowDivideByZero3, 3, DIVIDE_BY_ZERO, [start of procedure shouldThrowDivideByZero3(),start of procedure init,return from a call to Derived_init,Condition is true] codetoanalyze/objc/errors/variadic_methods/premature_nil_termination.m, PrematureNilTermA_nilInArrayWithObjects, 5, PREMATURE_NIL_TERMINATION_ARGUMENT, [start of procedure nilInArrayWithObjects] +codetoanalyze/objc/errors/memory_leaks_benchmark/CoreVideoExample.m, CoreVideoExample_cvpixelbuffer_not_released_leak, 1, MEMORY_LEAK, [start of procedure cvpixelbuffer_not_released_leak] codetoanalyze/objc/errors/memory_leaks_benchmark/NSData_models_tests.m, NSData_models_tests_macForIV:, 2, MEMORY_LEAK, [start of procedure macForIV:] codetoanalyze/objc/errors/memory_leaks_benchmark/NSString_models_tests.m, StringInitA_hexStringValue, 11, MEMORY_LEAK, [start of procedure hexStringValue,Skipping CFStringCreateWithBytesNoCopy(): function or method not found,Condition is false] codetoanalyze/objc/errors/npe/Fraction.m, test_virtual_call, 7, NULL_DEREFERENCE, [start of procedure test_virtual_call(),start of procedure setNumerator:,return from a call to Fraction_setNumerator:,start of procedure getNumerator,return from a call to Fraction_getNumerator,Condition is true] diff --git a/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CoreVideoExample.m b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CoreVideoExample.m new file mode 100644 index 000000000..d7dc20c0c --- /dev/null +++ b/infer/tests/codetoanalyze/objc/errors/memory_leaks_benchmark/CoreVideoExample.m @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 - present Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +#import +#import +#import + +CVPixelBufferRef MyCVPixelBufferCreate(); + +@interface CoreVideoExample : NSObject + +@end + +@implementation CoreVideoExample + +- (void)cvpixelbuffer_released_no_leak { + CVPixelBufferRef pxbuffer = MyCVPixelBufferCreate(); + CVPixelBufferRelease(pxbuffer); +} + +- (void)cvpixelbuffer_not_released_leak { + CVPixelBufferRef pxbuffer = MyCVPixelBufferCreate(); +} +@end