[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 02:56:50 PDT 2024


================
@@ -1695,6 +1707,12 @@ MallocChecker::processNewAllocation(const CXXAllocatorCall &Call,
   // MallocUpdateRefState() instead of MallocMemAux() which breaks the
   // existing binding.
   SVal Target = Call.getObjectUnderConstruction();
+  if (Call.getOriginExpr()->isArray()) {
+    std::optional<const Expr *> SizeEx = NE->getArraySize();
+    if (SizeEx)
----------------
steakhal wrote:

```suggestion
    if (auto SizeEx = NE->getArraySize())
```

https://github.com/llvm/llvm-project/pull/92420


More information about the cfe-commits mailing list