diff options
author | Thomas White <taw@physics.org> | 2014-12-14 16:55:14 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-12-14 16:55:14 +0100 |
commit | 391770cd92b1f3dc2d6800fed33eaf0a44325eb8 (patch) | |
tree | 6cdadb3781a949454cac58f1e5b03991abed7c82 | |
parent | 1a9b34cce39ca82981adc077b7624bdbe90b0158 (diff) |
Detect invalid event
-rw-r--r-- | libcrystfel/src/events.c | 2 | ||||
-rw-r--r-- | src/dw-hdfsee.c | 5 |
2 files changed, 7 insertions, 0 deletions
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; i<el->num_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]; |