llvm-project/lldb/unittests/Core
Pavel Labath f7e7fdd5cf Fix DataExtractor::PeekData for zero length peeks
Summary:
The function was returning the null pointer for peeks of size zero, which seems like a sensible
thing to do, but is actually pretty easy to get bitten by that if you are extracting a variable
length field which happens to be of zero length and then doing pointer arithmetic on that (which
SymbolFileDWARF does, and ended up crashing in case of empty DW_AT_location).

This changes the function to return a null pointer only when it gets queried for data which is
outside of the range of the extractor, which is more c++-y, as one can still do reasonable things
with pointers to data of size zero (think, end() iterators).

I also add a test and fix some signedness warnings in the existing data extractor tests.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D22755

llvm-svn: 276734
2016-07-26 08:11:57 +00:00
..
CMakeLists.txt Handle bit fields on big-endian systems correctly 2016-04-14 14:32:57 +00:00
DataExtractorTest.cpp Fix DataExtractor::PeekData for zero length peeks 2016-07-26 08:11:57 +00:00
ScalarTest.cpp Avoid an assertion failure when a bit field is extracted from a value of the same size. 2016-05-19 13:51:20 +00:00