From 391770cd92b1f3dc2d6800fed33eaf0a44325eb8 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 14 Dec 2014 16:55:14 +0100 Subject: Detect invalid event --- libcrystfel/src/events.c | 2 ++ src/dw-hdfsee.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c index d40d2021..b008eee6 100644 --- a/libcrystfel/src/events.c +++ b/libcrystfel/src/events.c @@ -239,6 +239,8 @@ int find_event(struct event *ev, struct event_list *el) { int i; + if ( ev == NULL ) return el->num_events; + for ( i=0; inum_events; i++ ) { if ( events_equal(ev, el->events[i]) ) return i; } diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 78f691b6..72e3b435 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -2546,6 +2546,11 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename, if ( event != NULL ) { ev = get_event_from_event_string(event); dw->curr_event = find_event(ev, dw->ev_list); + if ( dw->curr_event == dw->ev_list->num_events) + { + ERROR("Invalid event\n"); + return NULL; + } } else { dw->curr_event = 0; ev = dw->ev_list->events[dw->curr_event]; -- cgit v1.2.3