Skip to content

Commit ea9b316

Browse files
bdashemesare
authored andcommitted
[ObjC] Handle Objective-C ivars with an offset of 0
objc-runtime-new.mm mentions an offset of 0 is used for anonymous bitfields. Previously this would throw an exception when attempting to read from offset 0 and the types would not be applied.
1 parent 4892082 commit ea9b316

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

objectivec/objc.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,17 @@ void ObjCProcessor::ReadIvarList(ObjCReader* reader, ClassBase& cls, std::string
936936
ivarStruct.alignmentRaw = reader->Read32();
937937
ivarStruct.size = reader->Read32();
938938

939-
reader->Seek(ivarStruct.offset);
940-
ivar.offset = reader->Read32();
939+
if (ivarStruct.offset)
940+
{
941+
reader->Seek(ivarStruct.offset);
942+
ivar.offset = reader->Read32();
943+
}
944+
else
945+
{
946+
// `offset` can be 0 if the ivar is an anonymous bitfield.
947+
ivar.offset = 0;
948+
}
949+
941950
reader->Seek(ivarStruct.name);
942951
ivar.name = reader->ReadCString();
943952
reader->Seek(ivarStruct.type);

0 commit comments

Comments
 (0)