From f478a8f5a6a5c55f48a50004f87b258c69e72e5f Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Tue, 16 Sep 2025 09:49:22 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.6 --- llvm/lib/CAS/MappedFileRegionArena.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/lib/CAS/MappedFileRegionArena.cpp b/llvm/lib/CAS/MappedFileRegionArena.cpp index 2deb87d7adecf..472843d78af6e 100644 --- a/llvm/lib/CAS/MappedFileRegionArena.cpp +++ b/llvm/lib/CAS/MappedFileRegionArena.cpp @@ -216,17 +216,18 @@ Expected MappedFileRegionArena::create( if (!Size) return Size.takeError(); - Header *H = reinterpret_cast
(HeaderContent.data()); - if (H->HeaderOffset != HeaderOffset) + Header H; + memcpy(&H, HeaderContent.data(), sizeof(H)); + if (H.HeaderOffset != HeaderOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), "specified header offset (" + utostr(HeaderOffset) + - ") does not match existing config (" + utostr(H->HeaderOffset) + + ") does not match existing config (" + utostr(H.HeaderOffset) + ")"); // If the capacity doesn't match, use the existing capacity instead. - if (H->Capacity != Capacity) - Capacity = H->Capacity; + if (H.Capacity != Capacity) + Capacity = H.Capacity; } // If the size is smaller than capacity, we need to resize the file.