diff options
author | Alexander Shaposhnikov <shal1t712@gmail.com> | 2018-01-24 22:17:30 +0000 |
---|---|---|
committer | Alexander Shaposhnikov <shal1t712@gmail.com> | 2018-01-24 22:17:30 +0000 |
commit | 0c352b15d78e7fe2eff1d22799411f9be05b5ff2 (patch) | |
tree | 81e2705c8c34f863952fe35a97d6dc543640dce5 /clang/test/Analysis/malloc.c | |
parent | 61f4ac98e019e0e7ce5adbc58474fdcf7f49c300 (diff) | |
download | bcm5719-llvm-0c352b15d78e7fe2eff1d22799411f9be05b5ff2.tar.gz bcm5719-llvm-0c352b15d78e7fe2eff1d22799411f9be05b5ff2.zip |
[analyzer] Do not attempt to get the pointee of void*
Do not attempt to get the pointee of void* while generating a bug report
(otherwise it will trigger an assert inside RegionStoreManager::getBinding
assert(!T->isVoidType() && "Attempting to dereference a void pointer!")).
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D42396
llvm-svn: 323382
Diffstat (limited to 'clang/test/Analysis/malloc.c')
-rw-r--r-- | clang/test/Analysis/malloc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c index 6e3f3faaa17..50be4ef3ba2 100644 --- a/clang/test/Analysis/malloc.c +++ b/clang/test/Analysis/malloc.c @@ -1786,6 +1786,18 @@ void cstringchecker_bounds_nocrash() { free(p); } +void allocateSomeMemory(void *offendingParameter, void **ptr) { + *ptr = malloc(1); +} + +void testNoCrashOnOffendingParameter() { + // "extern" is necessary to avoid unrelated warnings + // on passing uninitialized value. + extern void *offendingParameter; + void* ptr; + allocateSomeMemory(offendingParameter, &ptr); +} // expected-warning {{Potential leak of memory pointed to by 'ptr'}} + // ---------------------------------------------------------------------------- // False negatives. |