]> granicus.if.org Git - clang/commit
[analyzer] If realloc fails on an escaped region, that region doesn't leak.
authorJordan Rose <jordan_rose@apple.com>
Thu, 15 Aug 2013 17:22:06 +0000 (17:22 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 15 Aug 2013 17:22:06 +0000 (17:22 +0000)
commit68502e52938f84b97267b51e86d4a90a11552512
tree878cbde7948bbd3d7ed9794051eaa91f99246d05
parenta44f03bced45059e7c4c7043992db3b4657032c2
[analyzer] If realloc fails on an escaped region, that region doesn't leak.

When a region is realloc()ed, MallocChecker records whether it was known
to be allocated or not. If it is, and the reallocation fails, the original
region has to be freed. Previously, when an allocated region escaped,
MallocChecker completely stopped tracking it, so a failed reallocation
still (correctly) wouldn't require freeing the original region. Recently,
however, MallocChecker started tracking escaped symbols, so that if it were
freed we could check that the deallocator matched the allocator. This
broke the reallocation model for whether or not a symbol was allocated.

Now, MallocChecker will actually check if a symbol is owned, and only
require freeing after a failed reallocation if it was owned before.

PR16730

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188468 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
test/Analysis/malloc.c