[PATCH] D137263: add boundary check for ASTUnresolvedSet::erase
zhouyizhou via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 2 09:09:31 PDT 2022
zhouyizhou updated this revision to Diff 472642.
zhouyizhou added a comment.
We should also consider the situation of erasing the size - 1th element
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137263/new/
https://reviews.llvm.org/D137263
Files:
clang/include/clang/AST/ASTUnresolvedSet.h
Index: clang/include/clang/AST/ASTUnresolvedSet.h
===================================================================
--- clang/include/clang/AST/ASTUnresolvedSet.h
+++ clang/include/clang/AST/ASTUnresolvedSet.h
@@ -69,7 +69,12 @@
return false;
}
- void erase(unsigned I) { Decls[I] = Decls.pop_back_val(); }
+ void erase(unsigned I) {
+ if (I == (Decls.size() - 1))
+ Decls.pop_back_val();
+ else
+ Decls[I] = Decls.pop_back_val();
+ }
void clear() { Decls.clear(); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137263.472642.patch
Type: text/x-patch
Size: 505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221102/311c2594/attachment.bin>
More information about the cfe-commits
mailing list