[lldb] Fix m_hwp_regs size for ppc64le (PR54520)
authorNikita Popov <npopov@redhat.com>
Tue, 18 Oct 2022 09:11:20 +0000 (11:11 +0200)
committerNikita Popov <npopov@redhat.com>
Tue, 18 Oct 2022 13:11:21 +0000 (15:11 +0200)
The size of the m_hwp_regs array should match the default value of
m_max_hwp_supported. This ensures that no out-of-bounds accesses
occur, even if the array is accessed prior to a call to
ReadHardwareDebugInfo().

Fixes https://github.com/llvm/llvm-project/issues/54520, see also
there for additional background.

Differential Revision: https://reviews.llvm.org/D136144

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.h

index fac3958..942c65f 100644 (file)
@@ -122,7 +122,7 @@ private:
     int mode;               // Defines if watchpoint is read/write/access.
   };
 
-  std::array<DREG, 4> m_hwp_regs;
+  std::array<DREG, 16> m_hwp_regs;
 
   // 16 is just a maximum value, query hardware for actual watchpoint count
   uint32_t m_max_hwp_supported = 16;