Skip to content

Commit 4e5a013

Browse files
committed
[lldb] Fix misaligned loads violation in DataExtractor
The implementation of the templated `Get` function contains UB. For example, the "GetDoubleUnaligned" unit test causes `Get` to perform an unaligned 8 byte read. This violates the `double` alignment requirement. Furthermore, it violates strict aliasing rules in C++. (We construct a `const double *` from a `const uint8_t *` and perform a read on the resulting double pointer). DataExtractor should be able to read unaligned data to deal with different data formats, but we need to be careful to not perform unaligned reads/writes or violate strict aliasing rules. rdar://160385383
1 parent 3e251e7 commit 4e5a013

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lldb/include/lldb/Utility/DataExtractor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ class DataExtractor {
994994
constexpr size_t src_size = sizeof(T);
995995
T val = fail_value;
996996

997-
const T *src = static_cast<const T *>(GetData(offset_ptr, src_size));
997+
const void *src = GetData(offset_ptr, src_size);
998998
if (!src)
999999
return val;
10001000

0 commit comments

Comments
 (0)