[clang] [clang][analyzer] Fix a nullptr dereference when -ftime-trace is used (Reland) (PR #139980)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu May 15 01:53:13 PDT 2025
================
@@ -101,9 +101,17 @@ class SymbolConjured : public SymbolData {
// It might return null.
const Stmt *getStmt() const {
+ if (const auto *Parent = Elem.getParent()) {
+ // Sometimes the CFG element is invalid, avoid dereferencing it.
+ if (Elem.getIndexInBlock() >= Parent->size())
+ return nullptr;
----------------
steakhal wrote:
WHen can the CFG element invalid? Where is it coming from?
My argument is that the CFG element should be always valid, and if it's not then my gut feeling is that that is because the CFG element is uninitialized. And I'm dreading uninitialized values because they are really hard to track down, and this is why I'm pushing back against this change to much just to be on the safe side.
https://github.com/llvm/llvm-project/pull/139980
More information about the cfe-commits
mailing list