Skip to content

Commit 033ca45

Browse files
committed
[llvm-readobj] Fix UB in pointer arithmetics after D105522
1 parent 14b71ef commit 033ca45

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/tools/llvm-readobj/ObjDumper.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ static void printAsPrintable(raw_ostream &W, const uint8_t *Start, size_t Len) {
5454

5555
void ObjDumper::printAsStringList(StringRef StringContent,
5656
size_t StringDataOffset) {
57+
if (StringContent.size() < StringDataOffset)
58+
return;
5759
const uint8_t *StrContent = StringContent.bytes_begin();
5860
// Some formats contain additional metadata at the start which should not be
5961
// interpreted as strings. Skip these bytes, but account for them in the

0 commit comments

Comments
 (0)