summaryrefslogtreecommitdiffstats
path: root/base/pickle.cc
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 00:50:25 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 00:50:25 +0000
commit522fbeaf970881e5293e8f75cf5534ffb5a20d42 (patch)
treec5144705628c421ad3b2ac9071c2b9246f8ca297 /base/pickle.cc
parent955f7416a711a1f8a1fe2b2a6704aca67bbc955f (diff)
downloadchromium_src-522fbeaf970881e5293e8f75cf5534ffb5a20d42.zip
chromium_src-522fbeaf970881e5293e8f75cf5534ffb5a20d42.tar.gz
chromium_src-522fbeaf970881e5293e8f75cf5534ffb5a20d42.tar.bz2
Force memcpy when reading a float, to avoid alignment issues
Despite our best efforts to align data when writing, when reading the data may not be sufficiently aligned, causing some ARM platforms to SIGBUS when reading floats. Force a memcpy instead to sidestep the issue. BUG=315213 Review URL: https://codereview.chromium.org/73333002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pickle.cc')
-rw-r--r--base/pickle.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/base/pickle.cc b/base/pickle.cc
index 70dfa0d..796fbc3 100644
--- a/base/pickle.cc
+++ b/base/pickle.cc
@@ -91,7 +91,15 @@ bool PickleIterator::ReadUInt64(uint64* result) {
}
bool PickleIterator::ReadFloat(float* result) {
- return ReadBuiltinType(result);
+ // crbug.com/315213
+ // The source data may not be properly aligned, and unaligned float reads
+ // cause SIGBUS on some ARM platforms, so force using memcpy to copy the data
+ // into the result.
+ const char* read_from = GetReadPointerAndAdvance<float>();
+ if (!read_from)
+ return false;
+ memcpy(result, read_from, sizeof(*result));
+ return true;
}
bool PickleIterator::ReadString(std::string* result) {