--- nagios-3.2.3/xdata/xodtemplate.c.orig 2010-11-08 20:20:51.000000000 +0100 +++ nagios-3.2.3/xdata/xodtemplate.c 2010-11-08 23:01:57.000000000 +0100 @@ -10192,16 +10192,18 @@ return ERROR; } #endif - for(host_name=strtok(this_hostgroup->members,",");host_name!=NULL;host_name=strtok(NULL,",")){ - strip(host_name); - new_hostsmember=add_host_to_hostgroup(new_hostgroup,host_name); - if(new_hostsmember==NULL){ + if(this_hostgroup->members!=NULL){ + for(host_name=strtok(this_hostgroup->members,",");host_name!=NULL;host_name=strtok(NULL,",")){ + strip(host_name); + new_hostsmember=add_host_to_hostgroup(new_hostgroup,host_name); + if(new_hostsmember==NULL){ #ifdef NSCORE - logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not add host '%s' to hostgroup (config file '%s', starting on line %d)\n",host_name,xodtemplate_config_file_name(this_hostgroup->_config_file),this_hostgroup->_start_line); + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not add host '%s' to hostgroup (config file '%s', starting on line %d)\n",host_name,xodtemplate_config_file_name(this_hostgroup->_config_file),this_hostgroup->_start_line); #endif - return ERROR; - } - } + return ERROR; + } + } + } return OK; } @@ -10239,25 +10241,27 @@ return ERROR; } #endif - for(host_name=strtok(this_servicegroup->members,",");host_name!=NULL;host_name=strtok(NULL,",")){ - strip(host_name); - svc_description=strtok(NULL,","); - if(svc_description==NULL){ + if(this_servicegroup->members!=NULL){ + for(host_name=strtok(this_servicegroup->members,",");host_name!=NULL;host_name=strtok(NULL,",")){ + strip(host_name); + svc_description=strtok(NULL,","); + if(svc_description==NULL){ #ifdef NSCORE - logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Missing service name in servicegroup definition (config file '%s', starting on line %d)\n",xodtemplate_config_file_name(this_servicegroup->_config_file),this_servicegroup->_start_line); + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Missing service name in servicegroup definition (config file '%s', starting on line %d)\n",xodtemplate_config_file_name(this_servicegroup->_config_file),this_servicegroup->_start_line); #endif - return ERROR; - } - strip(svc_description); + return ERROR; + } + strip(svc_description); - new_servicesmember=add_service_to_servicegroup(new_servicegroup,host_name,svc_description); - if(new_servicesmember==NULL){ + new_servicesmember=add_service_to_servicegroup(new_servicegroup,host_name,svc_description); + if(new_servicesmember==NULL){ #ifdef NSCORE - logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not add service '%s' on host '%s' to servicegroup (config file '%s', starting on line %d)\n",svc_description,host_name,xodtemplate_config_file_name(this_servicegroup->_config_file),this_servicegroup->_start_line); + logit(NSLOG_CONFIG_ERROR,TRUE,"Error: Could not add service '%s' on host '%s' to servicegroup (config file '%s', starting on line %d)\n",svc_description,host_name,xodtemplate_config_file_name(this_servicegroup->_config_file),this_servicegroup->_start_line); #endif - return ERROR; - } - } + return ERROR; + } + } + } return OK; }