Fixed bug when closing views with no associated predicate

This commit is contained in:
Celine Mercier
2016-08-12 15:52:38 +02:00
parent 64a745ce0b
commit 92cad61417

View File

@ -839,6 +839,13 @@ char* view_check_all_predicates(Obiview_p view)
char* all_predicates_string = NULL;
char** all_predicates = NULL;
if (view->nb_predicates == 0)
{
obi_set_errno(OBIVIEW_ERROR);
obidebug(1, "\nError trying to check predicates of a view with no predicates.");
return NULL;
}
size_to_allocate = 0;
// Allocate memory for predicate array
@ -1770,6 +1777,8 @@ int obi_save_and_close_view(Obiview_p view)
char* predicates;
if (!(view->read_only))
{
if (view->nb_predicates > 0)
{
predicates = view_check_all_predicates(view);
if (predicates == NULL)
@ -1780,6 +1789,7 @@ int obi_save_and_close_view(Obiview_p view)
strcat((view->infos)->comments, predicates);
free(predicates);
}
}
if (obi_save_view(view) < 0)
return -1;
}