diff options
author | Anna Zaks <ganna@apple.com> | 2012-05-03 23:50:28 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-05-03 23:50:28 +0000 |
commit | 228f9c7b68fd2bf56b32623251b54f3d3c9ee3b7 (patch) | |
tree | 267b6117d5f94254b376ca1ac9cccb9cec4443ee /clang/test/Analysis/malloc.c | |
parent | b41171b70b214ee529b01c3f6166e0b82229dabf (diff) | |
download | bcm5719-llvm-228f9c7b68fd2bf56b32623251b54f3d3c9ee3b7.tar.gz bcm5719-llvm-228f9c7b68fd2bf56b32623251b54f3d3c9ee3b7.zip |
[analyzer] Allow pointers escape through calls containing callback args.
(Since we don't have a generic pointer escape callback, modify
ExprEngineCallAndReturn as well as the malloc checker.)
llvm-svn: 156134
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r-- | clang/test/Analysis/malloc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index 9c09051c31b..f5bff4fa43b 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -798,6 +798,27 @@ void radar_11358224_test_double_assign_ints_positive_2() ptr = ptr; // expected-warning {{leak}} } +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +int const_ptr_and_callback(int, const char*, int n, void(*)(void*)); +void r11160612_1() { + char *x = malloc(12); + const_ptr_and_callback(0, x, 12, free); // no - warning +} + +// Null is passed as callback. +void r11160612_2() { + char *x = malloc(12); + const_ptr_and_callback(0, x, 12, 0); // expected-warning {{leak}} +} + +// Callback is passed to a function defined in a system header. +void r11160612_4() { + char *x = malloc(12); + sqlite3_bind_text_my(0, x, 12, free); // no - warning +} + // ---------------------------------------------------------------------------- // Below are the known false positives. |