[clang] [Clang][NFC] Fix out-of-bounds access (PR #77193)

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 07:18:39 PST 2024


https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/77193

>From b737ce548ad554bc351820cedd693b9f8737be45 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Sat, 6 Jan 2024 07:26:06 -0500
Subject: [PATCH] [Clang][NFC] Fix out-of-bounds access

---
 clang/include/clang/Analysis/CFG.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Analysis/CFG.h b/clang/include/clang/Analysis/CFG.h
index 67383bb316d318..9f776ca6cc260d 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -1215,7 +1215,9 @@ class CFG {
   //===--------------------------------------------------------------------===//
 
   class BuildOptions {
-    std::bitset<Stmt::lastStmtConstant> alwaysAddMask;
+    // Stmt::lastStmtConstant has the same value as the last Stmt kind,
+    // so make sure we add one to account for this!
+    std::bitset<Stmt::lastStmtConstant + 1> alwaysAddMask;
 
   public:
     using ForcedBlkExprs = llvm::DenseMap<const Stmt *, const CFGBlock *>;



More information about the cfe-commits mailing list