Commit 13af45c9 authored by thakis's avatar thakis Committed by Commit Bot

v8: Fix unaligned access when deserializing snapshots.

The code was already careful to use memcpy() here, but then it
added needless casts to wider types that made the compiler think
that it can do 4-byte-aligned accesses when it couldn't.

(It's also a bug that the snapshot got loaded at an unaligned
address, but we can fix both bugs.)

BUG=chromium:729059

Review-Url: https://codereview.chromium.org/2915323002
Cr-Commit-Position: refs/heads/master@{#45698}
parent 7ef542dc
......@@ -271,13 +271,12 @@ class SerializedData {
protected:
void SetHeaderValue(int offset, uint32_t value) {
uint32_t* address = reinterpret_cast<uint32_t*>(data_ + offset);
memcpy(reinterpret_cast<uint32_t*>(address), &value, sizeof(value));
memcpy(data_ + offset, &value, sizeof(value));
}
uint32_t GetHeaderValue(int offset) const {
uint32_t value;
memcpy(&value, reinterpret_cast<int*>(data_ + offset), sizeof(value));
memcpy(&value, data_ + offset, sizeof(value));
return value;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment