Hi All,
MallocChecker::addExtentSize() assumes that the region returned by CXXNewExpr is ElementRegion, but when the custom operator new [] is inlined, the region returned is not necessarily an ElementRegion.
Given the below code sippet:
#include <stdlib.h> void *operator new[](std::size_t size) { void *p = malloc(size); return p; } int main() { int *ptr = new int[10]; }
When operator new[] is inlined, the return region is Symbolic Region, which violates the MallocChecker::addExtentSize() assumption.
Digged a bit into this. This line should say return State;, otherwise it destroys the effort in checkPostStmt(const CXXNewExpr...) to actually track the pointer in the state.
However, testing for that would be really problematic because MallocChecker is suffering from another big problem in c++-allocator-inlining mode, namely this callback fires twice.
I'm going to describe this problem on the mailing list, because it's nasty.
I'd still wholeheartedly approve this patch with the return State change, because fixing crashes is important :)