Skip to content

Commit 9a5a609

Browse files
committed
Fixed occasional segfault
1 parent 3e24991 commit 9a5a609

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler-rt/lib/tysan/tysan.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ static bool isAliasingLegalUp(tysan_type_descriptor *TDA,
131131

132132
// This offset can't be negative. Therefore we must be accessing something
133133
// partially inside the last type
134-
if (TDA->Struct.Members[Idx].Offset > OffsetA)
134+
// We shouldn't check this if we are on the first member, Idx will underflow
135+
// The first member can be offset in rare cases such as llvm::cl::Option
136+
if (TDA->Struct.Members[Idx].Offset > OffsetA && Idx > 0)
135137
Idx -= 1;
136138

137139
OffsetA -= TDA->Struct.Members[Idx].Offset;

0 commit comments

Comments
 (0)