Don't allocate objects of size 0.

There's nowhere for the class pointer, so there's nothing that you can
do with them.
main
David Chisnall 8 years ago
parent 2bdf85ee50
commit 8021533d4c

@ -356,6 +356,9 @@ id class_createInstance(Class cls, size_t extraBytes)
}
if (Nil == cls) { return nil; }
// Don't try to allocate an object of size 0, because there's no space for
// its isa pointer!
if (cls->instance_size == 0) { return nil; }
id obj = gc->allocate_class(cls, extraBytes);
obj->isa = cls;
checkARCAccessorsSlow(cls);

Loading…
Cancel
Save