llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Nathan Gauër (Keenuts)

<details>
<summary>Changes</summary>

This was found by doing bound-checking on SmallVector iterator usage. When the 
count is 0, the end iterator is dereferenced to get its address. This doesn't 
seem to be an issue in practice as most of the time we should be allowed to 
deref this address, but I don't think this is correct.

---
Full diff: https://github.com/llvm/llvm-project/pull/70193.diff


1 Files Affected:

- (modified) clang/include/clang/Sema/CXXFieldCollector.h (+1-1) 


``````````diff
diff --git a/clang/include/clang/Sema/CXXFieldCollector.h 
b/clang/include/clang/Sema/CXXFieldCollector.h
index f6ecd9f46e5ebdb..ce066581c93fda7 100644
--- a/clang/include/clang/Sema/CXXFieldCollector.h
+++ b/clang/include/clang/Sema/CXXFieldCollector.h
@@ -65,7 +65,7 @@ class CXXFieldCollector {
 
   /// getCurFields - Pointer to array of fields added to the currently parsed
   /// class.
-  FieldDecl **getCurFields() { return &*(Fields.end() - getCurNumFields()); }
+  FieldDecl **getCurFields() { return Fields.end() - getCurNumFields(); }
 
   /// FinishClass - Called by Sema::ActOnFinishCXXClassDef.
   void FinishClass() {

``````````

</details>


https://github.com/llvm/llvm-project/pull/70193
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to