Explorar o código

throw error on negative allocation size

Nicolas Cannasse %!s(int64=2) %!d(string=hai) anos
pai
achega
2be3f7a9e6
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      src/gc.c

+ 2 - 0
src/gc.c

@@ -475,6 +475,8 @@ void *hl_gc_alloc_gen( hl_type *t, int size, int flags ) {
 	int allocated = 0;
 	if( size == 0 )
 		return NULL;
+	if( size < 0 )
+		hl_error("Invalid allocation size");
 	gc_global_lock(true);
 	gc_check_mark();
 #	ifdef GC_MEMCHK