From ab22d612621b4aedbc299387cd3e69d17d2840cd Mon Sep 17 00:00:00 2001 From: Sergey Popov Date: Fri, 25 Nov 2011 17:42:48 +0400 Subject: [PATCH] add check for empty hosts' list --- yasnd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yasnd.c b/yasnd.c index d6c8a65..9893ce9 100644 --- a/yasnd.c +++ b/yasnd.c @@ -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