Skip to content

Commit f478a8f

Browse files
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6
1 parent 3fe05ba commit f478a8f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/CAS/MappedFileRegionArena.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,18 @@ Expected<MappedFileRegionArena> MappedFileRegionArena::create(
216216
if (!Size)
217217
return Size.takeError();
218218

219-
Header *H = reinterpret_cast<Header *>(HeaderContent.data());
220-
if (H->HeaderOffset != HeaderOffset)
219+
Header H;
220+
memcpy(&H, HeaderContent.data(), sizeof(H));
221+
if (H.HeaderOffset != HeaderOffset)
221222
return createStringError(
222223
std::make_error_code(std::errc::invalid_argument),
223224
"specified header offset (" + utostr(HeaderOffset) +
224-
") does not match existing config (" + utostr(H->HeaderOffset) +
225+
") does not match existing config (" + utostr(H.HeaderOffset) +
225226
")");
226227

227228
// If the capacity doesn't match, use the existing capacity instead.
228-
if (H->Capacity != Capacity)
229-
Capacity = H->Capacity;
229+
if (H.Capacity != Capacity)
230+
Capacity = H.Capacity;
230231
}
231232

232233
// If the size is smaller than capacity, we need to resize the file.

0 commit comments

Comments
 (0)