[clang] [clang][analyzer] Fix a nullptr dereference when -ftime-trace is used (Reland) (PR #139980)
Fangyi Zhou via cfe-commits
cfe-commits at lists.llvm.org
Thu May 15 06:39:24 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;
----------------
fangyi-zhou wrote:
I'm getting a bit confused here. The issue at hand is that we have a valid `blockPtr` and an invalid index (`ptr` points to the correct CFG block, but the block has no elements, and the index is set to the default value of 0). Are you suggesting that we should check both the pointer and the index?
https://github.com/llvm/llvm-project/pull/139980
More information about the cfe-commits
mailing list