Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1394)

Unified Diff: src/serialize.h

Issue 841943002: Fix unsafe unaligned accesses in the serializer/deserializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.h
diff --git a/src/serialize.h b/src/serialize.h
index bd0c423a6aa8281838806e682afdabd7723b641e..5dc73745baab1d08cea857372b94a5bc8e7644a5 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -482,11 +482,13 @@ class SerializedData {
protected:
void SetHeaderValue(int offset, int value) {
- reinterpret_cast<int*>(data_)[offset] = value;
+ memcpy(reinterpret_cast<int*>(data_) + offset, &value, sizeof(value));
}
int GetHeaderValue(int offset) const {
- return reinterpret_cast<const int*>(data_)[offset];
+ int value;
+ memcpy(&value, reinterpret_cast<int*>(data_) + offset, sizeof(value));
+ return value;
}
void AllocateData(int size);
@@ -544,6 +546,10 @@ class Deserializer: public SerializerDeserializer {
bool ReserveSpace();
+ void UnalignedCopy(Object** dest, Object** src) {
+ memcpy(dest, src, sizeof(*src));
+ }
+
// Allocation sites are present in the snapshot, and must be linked into
// a list at deserialization time.
void RelinkAllocationSite(AllocationSite* site);
« no previous file with comments | « no previous file | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698