summaryrefslogtreecommitdiff
path: root/Objective-C
diff options
context:
space:
mode:
Diffstat (limited to 'Objective-C')
-rw-r--r--Objective-C/libobjcl.m13
1 files changed, 9 insertions, 4 deletions
diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m
index f49d502..7c1c186 100644
--- a/Objective-C/libobjcl.m
+++ b/Objective-C/libobjcl.m
@@ -406,10 +406,15 @@ objcl_class_direct_slots (Class class, unsigned int *count, unsigned int *elemen
#ifdef __NEXT_RUNTIME__
ivars = class_copyIvarList (class, count);
#else
- *count = class->ivars->ivar_count;
- ivars = malloc ((*count) * (*element_size));
- for (i = 0; i < *count; i++)
- ivars[i] = &class->ivars->ivar_list[i];
+ *count = (class->ivars ? class->ivars->ivar_count : 0);
+ if (!*count)
+ ivars = NULL;
+ else
+ {
+ ivars = malloc ((*count) * (*element_size));
+ for (i = 0; i < *count; i++)
+ ivars[i] = &class->ivars->ivar_list[i];
+ }
#endif
return ivars;