summaryrefslogtreecommitdiff
path: root/objectivec/objc.cpp
diff options
context:
space:
mode:
authorMark Rowe <mrowe@bdash.net.nz>2025-04-06 21:34:12 -0700
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-04-08 18:03:10 -0400
commitea9b31650f0a56d5a44740e6fc57b8b3b34ffd7d (patch)
treef842ad6410b8f092b69fe0e76a8236dcecc961be /objectivec/objc.cpp
parent4892082706563431474049823269238098095978 (diff)
[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.
Diffstat (limited to 'objectivec/objc.cpp')
-rw-r--r--objectivec/objc.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/objectivec/objc.cpp b/objectivec/objc.cpp
index 7d110450..9bdd61c3 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);