add check for empty hosts' list

This commit is contained in:
Sergey Popov 2011-11-25 17:42:48 +04:00
parent bc7c1edb41
commit ab22d61262

View File

@ -63,8 +63,14 @@ void init()
log_event("Error parsing config file");
exit(EXIT_FAILURE);
}
// allocate memory for hosts array...
// hosts' array must not be empty
hosts_count=cfg_size(cfg,"hosts");
if (hosts_count==0)
{
log_event("Error: no hosts to check defined in config file");
exit(EXIT_FAILURE);
}
// allocate memory for hosts array...
hosts=allocate_memory(hosts_count*sizeof(host_decl));
// ...and fill it with config file content
for (int i=0;i<hosts_count;i++)