This is an archive of the discontinued LLVM Phabricator instance.

Fix DataExtractor::PeekData for zero length peeks
ClosedPublic

Authored by labath on Jul 25 2016, 7:07 AM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 65339.Jul 25 2016, 7:07 AM
labath retitled this revision from to Fix DataExtractor::PeekData for zero length peeks.
labath updated this object.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.
clayborg accepted this revision.Jul 25 2016, 10:41 AM
clayborg edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Jul 25 2016, 10:41 AM
This revision was automatically updated to reflect the committed changes.