Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -402,7 +402,7 @@ if (!Cont) return; - // At least one of the iterators have recorded positions. If one of them has + // At least one of the iterators has recorded positions. If one of them does // not then create a new symbol for the offset. SymbolRef Sym; if (!LPos || !RPos) { @@ -422,9 +422,14 @@ RPos = getIteratorPosition(State, RVal); } - // We cannot make assumpotions on `UnknownVal`. Let us conjure a symbol + if (!LPos || !RPos) + return; + + // We cannot make assumptions on `UnknownVal`. Let us conjure a symbol // instead. if (RetVal.isUnknown()) { + if (!State) + return; auto &SymMgr = C.getSymbolManager(); auto *LCtx = C.getLocationContext(); RetVal = nonloc::SymbolVal(SymMgr.conjureSymbol( @@ -532,8 +537,9 @@ return; const auto *value = &RHS; + SVal val; if (auto loc = RHS.getAs()) { - const auto val = State->getRawSVal(*loc); + val = State->getRawSVal(*loc); value = &val; }