void foo(int bufferSize) { if (bufferSize < 0) CheckerContext->generateSink("Negative buffer size provided"); else char* buffer = (char*)malloc(bufferSize); }
void bar(const char* str) { size_t length = strlen(str); if (str[length] != '\0') CheckerContext->generateSink("String not null-terminated"); else // do something with the string }The Clang Static Analyzer is part of the LLVM toolchain and can be installed as a separate package or library.