Skip to content

Commit

Permalink
More segmentation faults perl11#87
Browse files Browse the repository at this point in the history
Remove the possibility for the user to create a "special" object that doesn't have a constructor.
Disable subclassing any of the "special" types built-in to the system.
  • Loading branch information
robotii committed Nov 10, 2015
1 parent f7c451e commit 5d0ef8a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/objmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ void potion_type_constructor_is(PN vt, PN cl) {
///\param ivars: PNTuple of object members
PN potion_class(Potion *P, PN cl, PN self, PN ivars) {
PN parent = ((!self || self == P->lobby) ? PN_VTABLE(PN_TOBJECT) : self);
if(((struct PNVtable *)parent)->type <= PN_TUSER && ((struct PNVtable *)parent)->type != PN_TOBJECT)
return PN_NIL;
PN pvars = ((struct PNVtable *)parent)->ivars;
PNType t = PN_FLEX_SIZE(P->vts) + PN_TNIL;
PN_FLEX_NEEDS(1, P->vts, PN_TFLEX, PNFlex, TYPE_BATCH_SIZE);
Expand Down Expand Up @@ -531,6 +533,8 @@ PN potion_object_new(Potion *P, PN cl, PN self) {
vPN(Vtable) vt = (struct PNVtable *)self;
if (PN_IS_METACLASS(vt)) // TODO: error
return PN_NIL;
if(vt->type <= PN_TUSER && vt->type != PN_TOBJECT)
return PN_NIL;
if (vt->type == PN_TVTABLE) // TODO: error
return PN_NIL;
return (PN)PN_ALLOC_N(vt->type, struct PNObject,
Expand Down

0 comments on commit 5d0ef8a

Please sign in to comment.