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

Unified Diff: third_party/jsoncpp/overrides/src/lib_json/json_value.cpp

Issue 24984004: jsoncpp: force alignment of Json::Value::null to avoid crashes on ARM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/jsoncpp/overrides/src/lib_json/json_value.cpp
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 850724fd3e3826f099bb3e4554c9b0aa529ad5b7..a2a4a6761d2cdb346c0764c5dd84266cc7619d3a 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<const Value&>(kNull);
const Int Value::minInt = Int( ~(UInt(-1)/2) );
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698