From 29b4a4cbe337b91f0543dc919f4a43e3783e89f2 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Sun, 6 Apr 2025 21:34:12 -0700 Subject: [PATCH] [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. --- objectivec/objc.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/objectivec/objc.cpp b/objectivec/objc.cpp index 7d11045052..9bdd61c3c6 100644 --- a/objectivec/objc.cpp +++ b/objectivec/objc.cpp @@ -936,8 +936,17 @@ void ObjCProcessor::ReadIvarList(ObjCReader* reader, ClassBase& cls, std::string ivarStruct.alignmentRaw = reader->Read32(); ivarStruct.size = reader->Read32(); - reader->Seek(ivarStruct.offset); - ivar.offset = reader->Read32(); + if (ivarStruct.offset) + { + reader->Seek(ivarStruct.offset); + ivar.offset = reader->Read32(); + } + else + { + // `offset` can be 0 if the ivar is an anonymous bitfield. + ivar.offset = 0; + } + reader->Seek(ivarStruct.name); ivar.name = reader->ReadCString(); reader->Seek(ivarStruct.type);