[PATCH] [libcxx] Fix PR21580 - Undefined behavior in readEncodedPointer()

Saleem Abdulrasool compnerd at compnerd.org
Mon Mar 9 18:31:35 PDT 2015


I imagine that you couldn't give a bit more context on what platform/environment you managed to get the unaligned read for future reference.  We should get the change in irrespective of that.


================
Comment at: src/cxa_personality.cpp:145
@@ -143,1 +144,3 @@
 
+namespace
+{
----------------
Any reason to have this in the __cxxabiv1::(anonymous namespace) rather than (anonymous namespace)?  Maybe mark the function static and ignore the namespacing as the trend in the rest of LLVM has been?

================
Comment at: src/cxa_personality.cpp:148
@@ +147,3 @@
+
+template <class FromType>
+uintptr_t readPointerHelper(const uint8_t*& p) {
----------------
FromType is poorly chosen I think.  AsType might be better.  The data is being read from a uint8_t *, but being read as the type specified.

================
Comment at: src/cxa_personality.cpp:151
@@ +150,3 @@
+    FromType from;
+    memcpy(&from, (void*)p, sizeof(FromType));
+    p += sizeof(FromType);
----------------
Please use the appropriate new (C++) style cast here.

http://reviews.llvm.org/D8179

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list