]> granicus.if.org Git - clang/commit
[analyzer] Malloc checker: rework realloc handling:
authorAnna Zaks <ganna@apple.com>
Mon, 13 Feb 2012 18:05:39 +0000 (18:05 +0000)
committerAnna Zaks <ganna@apple.com>
Mon, 13 Feb 2012 18:05:39 +0000 (18:05 +0000)
commitc8bb3befcad8cd8fc9556bc265289b07dc3c94c8
treeacc089b65cf59aef5eb12203b490f072197b94b4
parent7ae282fde0a12635893931ebf31b35b0d5d5cab3
[analyzer] Malloc checker: rework realloc handling:

1) Support the case when realloc fails to reduce False Positives. (We
essentially need to restore the state of the pointer being reallocated.)

2) Realloc behaves differently under special conditions (from pointer is
null, size is 0). When detecting these cases, we should consider
under-constrained states (size might or might not be 0). The
old version handled this in a very hacky way. The code did not
differentiate between definite and possible (no consideration for
under-constrained states). Further, after processing each special case,
the realloc processing function did not return but chained to the next
special case processing. So you could end up in an execution in which
you first see the states in which size is 0 and realloc ~ free(),
followed by the states corresponding to size is not 0 followed by the
evaluation of the regular realloc behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150402 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
test/Analysis/malloc.c