浏览代码

fixed alloc_enum

Nicolas Cannasse 8 年之前
父节点
当前提交
4c04c9eb96
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/std/types.c

+ 3 - 3
src/std/types.c

@@ -401,12 +401,12 @@ HL_PRIM bool hl_type_enum_eq( vdynamic *a, vdynamic *b ) {
 	return true;
 }
 
-HL_PRIM vdynamic *hl_alloc_enum( hl_type *t, int index, varray *args ) {
+HL_PRIM vdynamic *hl_alloc_enum( hl_type *t, int index, varray *args, int nargs ) {
 	hl_enum_construct *c = t->tenum->constructs + index;
 	venum *e;
 	vdynamic *v;
 	int i;
-	if( c->nparams != args->size )
+	if( c->nparams != nargs || args->size < nargs )
 		return NULL;
 	e = (venum*)(c->hasptr ? hl_gc_alloc_raw(c->size) : hl_gc_alloc_noptr(c->size));
 	e->index = index;
@@ -436,5 +436,5 @@ DEFINE_PRIM(_TYPE, type_super, _TYPE);
 DEFINE_PRIM(_DYN, type_get_global, _TYPE);
 DEFINE_PRIM(_ARR, type_enum_fields, _TYPE);
 DEFINE_PRIM(_BOOL, type_enum_eq, _DYN _DYN);
-DEFINE_PRIM(_DYN, alloc_enum, _TYPE _I32 _ARR);
+DEFINE_PRIM(_DYN, alloc_enum, _TYPE _I32 _ARR _I32);
 DEFINE_PRIM(_ARR, enum_parameters, _DYN);