From d20057a048c37ffff0b5a09a2d07acd25cb69eaf Mon Sep 17 00:00:00 2001 From: "fischman@chromium.org" Date: Tue, 1 Oct 2013 01:03:54 +0000 Subject: 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: svn://svn.chromium.org/chrome/trunk/src@226099 0039d316-1c4b-4281-b951-d872f2087c98 --- third_party/jsoncpp/overrides/src/lib_json/json_value.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'third_party/jsoncpp') diff --git a/third_party/jsoncpp/overrides/src/lib_json/json_value.cpp b/third_party/jsoncpp/overrides/src/lib_json/json_value.cpp index 850724f..a2a4a67 100644 --- a/third_party/jsoncpp/overrides/src/lib_json/json_value.cpp +++ b/third_party/jsoncpp/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(kNull); const Int Value::minInt = Int( ~(UInt(-1)/2) ); -- cgit v1.1