commit | c64d454a20383b55bac7219e92f11db869770389 | [log] [tgz] |
---|---|---|
author | fischman@chromium.org <fischman@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c> | Tue Oct 01 01:03:54 2013 |
committer | fischman@chromium.org <fischman@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c> | Tue Oct 01 01:03:54 2013 |
tree | b0fc07c4a180f2596052263a0537911488ff1321 | |
parent | 8b7fa821bd710367237002946d86fb5892376eba [diff] |
jsoncpp: force alignment of Json::Value::null to avoid crashes on ARM. BUG=109997,https://code.google.com/p/webrtc/issues/detail?id=1777 Review URL: https://codereview.chromium.org/24984004 git-svn-id: http://src.chromium.org/svn/trunk/src/third_party/jsoncpp@226099 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/overrides/src/lib_json/json_value.cpp b/overrides/src/lib_json/json_value.cpp index 850724f..a2a4a67 100644 --- a/overrides/src/lib_json/json_value.cpp +++ b/overrides/src/lib_json/json_value.cpp
@@ -27,8 +27,14 @@ namespace Json { // This is a walkaround to avoid the static initialization of Value::null. -// const Value Value::null; -static const unsigned char kNull[sizeof(Value)] = { 0 }; +// kNull must be word-aligned to avoid crashing on ARM. We use an alignment of +// 8 (instead of 4) as a bit of future-proofing. +#if defined(__ARMEL__) +#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) +#else +#define ALIGNAS(byte_alignment) +#endif +static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = {0}; const Value& Value::null = reinterpret_cast<const Value&>(kNull); const Int Value::minInt = Int( ~(UInt(-1)/2) );