[clang] [analyzer] Harden security.cert.env.InvalidPtr checker fn matching (PR #88536)
Ilya A. Kriveshko via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 16 10:56:32 PDT 2024
================
@@ -205,8 +210,12 @@ void InvalidPtrChecker::postPreviousReturnInvalidatingCall(
CE, LCtx, CE->getType(), C.blockCount());
State = State->BindExpr(CE, LCtx, RetVal);
+ const auto *SymRegOfRetVal =
+ dyn_cast_or_null<SymbolicRegion>(RetVal.getAsRegion());
+ if (!SymRegOfRetVal)
+ return;
+
// Remember to this region.
- const auto *SymRegOfRetVal = cast<SymbolicRegion>(RetVal.getAsRegion());
const MemRegion *MR = SymRegOfRetVal->getBaseRegion();
----------------
iillyyaa wrote:
If this (and the corresponding clang/test/Analysis/invalid-ptr-checker.cpp test) were put into a separate commit from the CDM::CLibrary changes, then this commit would be more easily back-ported into llvm:release/18.x branch.
I cannot tell how critical the CDM::CLibrary change is, but I have confirmed that the crash I had originally reported in https://github.com/llvm/llvm-project/issues/88181 is fixed with just the highlighted change when applied to clang18.
https://github.com/llvm/llvm-project/pull/88536
More information about the cfe-commits
mailing list