[llvm-readobj] Fix UB in pointer arithmetics after D105522

This commit is contained in:
Vitaly Buka 2021-08-03 10:29:30 -07:00
parent 14b71efd97
commit 033ca45d4f
1 changed files with 2 additions and 0 deletions

View File

@ -54,6 +54,8 @@ static void printAsPrintable(raw_ostream &W, const uint8_t *Start, size_t Len) {
void ObjDumper::printAsStringList(StringRef StringContent,
size_t StringDataOffset) {
if (StringContent.size() < StringDataOffset)
return;
const uint8_t *StrContent = StringContent.bytes_begin();
// Some formats contain additional metadata at the start which should not be
// interpreted as strings. Skip these bytes, but account for them in the