From c58ba234708dea24779a22f0d844695a59aaa1d7 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Fri, 1 Jan 2016 12:34:43 +0000 Subject: [PATCH] Improve some null handling in ivar resolution code. --- ivar.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ivar.c b/ivar.c index 37f99d7..7752155 100644 --- a/ivar.c +++ b/ivar.c @@ -15,6 +15,15 @@ static struct objc_ivar_list *upgradeIvarList(Class cls, struct objc_ivar_list_l PRIVATE void objc_compute_ivar_offsets(Class class) { struct objc_ivar_list_legacy *legacy = NULL; + if (class->ivars == NULL) + { + Class super_class = class_getSuperclass(class); + if (super_class != Nil) + { + class->instance_size = super_class->instance_size; + } + return; + } // If this is an old ABI class, then replace the ivar list with the new // version if (objc_get_class_version(class) < 3) @@ -81,7 +90,10 @@ PRIVATE void objc_compute_ivar_offsets(Class class) } // If we have a legacy ivar list, update the offset in it too - // code from older compilers may access this directly! - legacy->ivar_list[i].offset = ivar->offset; + if (legacy != NULL) + { + legacy->ivar_list[i].offset = ivar->offset; + } } } }