[llvm] [Object] Parsing and dumping of SFrame FDEs (PR #149828)

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 24 07:14:22 PDT 2025


================
@@ -14,23 +14,35 @@
 using namespace llvm;
 using namespace llvm::object;
 
-template <typename T>
-static Expected<const T &> getDataSliceAs(ArrayRef<uint8_t> Data,
-                                          uint64_t Offset) {
-  static_assert(std::is_trivial_v<T>);
-  if (Data.size() < Offset + sizeof(T)) {
+static Expected<ArrayRef<uint8_t>>
+getDataSlice(ArrayRef<uint8_t> Data, uint64_t Offset, uint64_t Size) {
+  // Check for overflow.
+  if (Offset + Size < Offset || Offset + Size < Size ||
----------------
labath wrote:

Yeah, I guess it will, though now that I think about this, I believe this actually cannot overflow as all offsets in the file are 32 bit (and I'm using 64-bit arithmetic). Let me put an assert there instead.

https://github.com/llvm/llvm-project/pull/149828


More information about the llvm-commits mailing list