diff --git a/src/obiview.c b/src/obiview.c index 1666f93..bd6712d 100644 --- a/src/obiview.c +++ b/src/obiview.c @@ -1561,13 +1561,29 @@ int obi_view_unmap_file(OBIDMS_p dms, Obiview_infos_p view_infos) Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name) { - Obiview_p view; - const char* column_name; - obiversion_t column_version; - OBIDMS_column_p column_pointer; - int i; + Obiview_p view; + const char* column_name; + obiversion_t column_version; + OBIDMS_column_p column_pointer; + int i; - // Alllocate the memory for the view structure + // Check that the DMS is a valid pointer + if (dms == NULL) + { + obi_set_errno(OBIVIEW_ERROR); + obidebug(1, "\nError opening a view: DMS pointer is NULL"); + return NULL; + } + + // Check that the view name pointer is valid + if (view_name == NULL) + { + obi_set_errno(OBIVIEW_ERROR); + obidebug(1, "\nError opening a view: view name is NULL"); + return NULL; + } + + // Allocate the memory for the view structure view = (Obiview_p) malloc(sizeof(Obiview_t)); if (view == NULL) {