From 4fd1b5b186fabcba09316881c56d83a7ea854b72 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 22 Nov 2024 05:04:53 -0600 Subject: [PATCH] fix: big endian bug in V8 serialization (#44776) --- shell/common/v8_util.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/common/v8_util.cc b/shell/common/v8_util.cc index 80a9300e7a2cf..463ef545ed7d6 100644 --- a/shell/common/v8_util.cc +++ b/shell/common/v8_util.cc @@ -4,6 +4,7 @@ #include "shell/common/v8_util.h" +#include #include #include @@ -20,11 +21,11 @@ namespace electron { namespace { -enum SerializationTag { - kNativeImageTag = 'i', - kTrailerOffsetTag = 0xFE, - kVersionTag = 0xFF -}; + +constexpr uint8_t kNativeImageTag = 'i'; +constexpr uint8_t kTrailerOffsetTag = 0xFE; +constexpr uint8_t kVersionTag = 0xFF; + } // namespace class V8Serializer : public v8::ValueSerializer::Delegate { @@ -104,7 +105,7 @@ class V8Serializer : public v8::ValueSerializer::Delegate { } private: - void WriteTag(SerializationTag tag) { serializer_.WriteRawBytes(&tag, 1); } + void WriteTag(const uint8_t tag) { serializer_.WriteRawBytes(&tag, 1U); } void WriteBlinkEnvelope(uint32_t blink_version) { // Write a dummy blink version envelope for compatibility with