From 4630346fd10337a84033061cb1ff8ffef397e04d Mon Sep 17 00:00:00 2001 From: Wiktor Garbacz Date: Fri, 27 Oct 2023 00:34:21 -0700 Subject: [PATCH] Fix unaligned load PiperOrigin-RevId: 577106224 Change-Id: Icd0e113031d367fa30557d4e77571abc78e8e378 --- sandboxed_api/tools/clang_generator/diagnostics.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sandboxed_api/tools/clang_generator/diagnostics.cc b/sandboxed_api/tools/clang_generator/diagnostics.cc index d64cb26..a8880be 100644 --- a/sandboxed_api/tools/clang_generator/diagnostics.cc +++ b/sandboxed_api/tools/clang_generator/diagnostics.cc @@ -15,6 +15,7 @@ #include "sandboxed_api/tools/clang_generator/diagnostics.h" #include +#include #include #include "absl/status/status.h" @@ -50,8 +51,9 @@ absl::optional GetDiagnosticLocationFromStatus( if (auto payload = status.GetPayload(kSapiStatusPayload).value_or(absl::Cord()); payload.size() == sizeof(uint64_t)) { - return clang::SourceLocation::getFromRawEncoding( - *reinterpret_cast(payload.Flatten().data())); + uint64_t raw_encoding = 0; + memcpy(&raw_encoding, payload.Flatten().data(), sizeof(raw_encoding)); + return clang::SourceLocation::getFromRawEncoding(raw_encoding); } return absl::nullopt; }