[analyzer] Report bugs when freeing memory with offset pointer
authorAnna Zaks <ganna@apple.com>
Thu, 7 Feb 2013 23:05:47 +0000 (23:05 +0000)
committerAnna Zaks <ganna@apple.com>
Thu, 7 Feb 2013 23:05:47 +0000 (23:05 +0000)
commitc89ad07d39a435a4069f890417747487f4b3abbf
tree802d570dd3c71cb8526b933cdeca91435b61c515
parentacdc13cb00591e2ab2b168c7924d7eb57fa4808e
[analyzer] Report bugs when freeing memory with offset pointer

The malloc checker will now catch the case when a previously malloc'ed
region is freed, but the pointer passed to free does not point to the
start of the allocated memory. For example:

int *p1 = malloc(sizeof(int));
p1++;
free(p1); // warn

From the "memory.LeakPtrValChanged enhancement to unix.Malloc" entry
in the list of potential checkers.

A patch by Branden Archer!

llvm-svn: 174678
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/test/Analysis/malloc.c