diff --git a/src/object.c b/src/object.c
index d893991f0db5998ce5c201187382f083148d1038..6413ef5ad83d8421caa48b3f329bf25e52ab63d8 100644
--- a/src/object.c
+++ b/src/object.c
@@ -2130,6 +2130,7 @@ PMOD_EXPORT struct array *object_types(struct object *o, int inherit_number)
     {
       struct identifier *id = ID_FROM_INT(p,p->identifier_index[e]);
       SET_SVAL(ITEM(a)[e], PIKE_T_TYPE, 0, type, id->type);
+      add_ref(id->type);
     }
     a->type_field = BIT_TYPE;
   }else{