Skip to content

Commit 45956ec

Browse files
committed
Fix asan error
1 parent 87b3299 commit 45956ec

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ class SymbolConjured : public SymbolData {
101101

102102
// It might return null.
103103
const Stmt *getStmt() const {
104+
if (const auto *Parent = Elem.getParent()) {
105+
// Sometimes the CFG element is invalid, avoid dereferencing it.
106+
if (Elem.getIndexInBlock() >= Parent->size())
107+
return nullptr;
108+
}
104109
switch (Elem->getKind()) {
105110
case CFGElement::Initializer:
106111
if (const auto *Init = Elem->castAs<CFGInitializer>().getInitializer()) {

0 commit comments

Comments
 (0)