[clang] Fix null-deref thanks to an attribute on a global declarator chunk (PR #83611)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 2 07:53:26 PST 2024
================
@@ -100,6 +100,12 @@ void AttributePool::takePool(AttributePool &pool) {
pool.Attrs.clear();
}
+void AttributePool::takeFrom(ParsedAttributesView &List, AttributePool &Pool) {
+ assert(&Pool != this && "AttributePool can't take attributes from itself");
+ llvm::for_each(List.AttrList, [&Pool](ParsedAttr *A) { Pool.remove(A); });
----------------
erichkeane wrote:
You mean reverse the order of the remove/add? Based on `takeAllFrom` and `takeOneFrom` (https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Sema/ParsedAttr.h#L953), we are consistently inconsistent :)
In this case, I was working from `takeOneFrom` so I ended up in this order, but if there is a good reason to prefer one over the other, I can switch.
https://github.com/llvm/llvm-project/pull/83611
More information about the cfe-commits
mailing list