Skip to content

Commit

Permalink
[pseudo] Fix an out-of-bound access for LRTable::Actions.
Browse files Browse the repository at this point in the history
Without this patch, when End == Start, we access Actions[Actions.end()]
though we return an empty result.
This fixes an assertion failure in MSVC STL debug build.
  • Loading branch information
hokein committed Mar 3, 2022
1 parent 6fc753a commit 28ccf32
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/lib/Tooling/Syntax/Pseudo/LRTable.cpp
Expand Up @@ -112,6 +112,8 @@ llvm::ArrayRef<LRTable::Action> LRTable::find(StateID Src, SymbolID ID) const {
"subrange of the StateIdx should be sorted!");
const LRTable::StateID *Start = llvm::partition_point(
TargetedStates, [&Src](LRTable::StateID S) { return S < Src; });
if (Start == TargetedStates.end())
return {};
const LRTable::StateID *End = Start;
while (End != TargetedStates.end() && *End == Src)
++End;
Expand Down

0 comments on commit 28ccf32

Please sign in to comment.