check case when index_name is NULL

This commit is contained in:
Laurent Vivier 2007-08-26 19:22:12 +00:00
parent 37d9728374
commit 0319bb29f2

View File

@ -15,23 +15,27 @@ int config_find_indexed_property(char *configuration, char *index_name, char *in
int last_index; int last_index;
char current_name[256]; char current_name[256];
index = config_find_entry(configuration, index_name, index_property); if (index_name == NULL)
if (index == -1) index = 0;
return -1; else
while (configuration[index]) index = config_find_entry(configuration, index_name, index_property);
while ((index != -1) && configuration[index])
{ {
last_index = index; last_index = index;
index = config_get_next_property(configuration, index, index = config_get_next_property(configuration, index,
current_name, property); current_name, property);
if (index == -1)
return -1;
if (strcmp(name, current_name) == 0) if ((name != NULL) && strcmp(name, current_name) == 0)
return last_index; return last_index;
if ((index_name != NULL) && if ((index_name != NULL) &&
(strcmp(index_name, current_name) == 0)) (strcmp(index_name, current_name) == 0))
{
if (name == NULL)
return last_index;
return -1; return -1;
}
} }
return -1; return -1;
} }