It's not that simple. At least, you also need to check for invalid free. This code already exists in Deallocate, but it is called too late in your case. So, we probably need to factor it out into a separate function http://llvm-reviews.chandlerc.com/D818