Fix unaligned load

PiperOrigin-RevId: 577106224
Change-Id: Icd0e113031d367fa30557d4e77571abc78e8e378
This commit is contained in:
Wiktor Garbacz 2023-10-27 00:34:21 -07:00 committed by Copybara-Service
parent 0940a9ee4a
commit 4630346fd1

View File

@ -15,6 +15,7 @@
#include "sandboxed_api/tools/clang_generator/diagnostics.h" #include "sandboxed_api/tools/clang_generator/diagnostics.h"
#include <cstdint> #include <cstdint>
#include <cstring>
#include <utility> #include <utility>
#include "absl/status/status.h" #include "absl/status/status.h"
@ -50,8 +51,9 @@ absl::optional<clang::SourceLocation> GetDiagnosticLocationFromStatus(
if (auto payload = if (auto payload =
status.GetPayload(kSapiStatusPayload).value_or(absl::Cord()); status.GetPayload(kSapiStatusPayload).value_or(absl::Cord());
payload.size() == sizeof(uint64_t)) { payload.size() == sizeof(uint64_t)) {
return clang::SourceLocation::getFromRawEncoding( uint64_t raw_encoding = 0;
*reinterpret_cast<const uint64_t*>(payload.Flatten().data())); memcpy(&raw_encoding, payload.Flatten().data(), sizeof(raw_encoding));
return clang::SourceLocation::getFromRawEncoding(raw_encoding);
} }
return absl::nullopt; return absl::nullopt;
} }