Explorar o código

core: safety check when declaring a cfg structure with empty content

Daniel-Constantin Mierla %!s(int64=11) %!d(string=hai) anos
pai
achega
6f47c9ee24
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      cfg/cfg.c

+ 3 - 0
cfg/cfg.c

@@ -46,6 +46,9 @@ int cfg_declare(char *group_name, cfg_def_t *def, void *values, int def_size,
 	cfg_group_t	*group;
 	int types;
 
+	if(def==NULL || def[0].name==NULL)
+		return -1;
+
 	/* check the number of the variables */
 	for (num=0; def[num].name; num++);