From 73e607d41d86db212cb1a6943a2174ad099c8720 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 9 Aug 2012 11:47:00 +0200 Subject: Fix crash when there are too many unit cell candidates --- libcrystfel/src/cell.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/cell.c b/libcrystfel/src/cell.c index 84361414..3d2a28bf 100644 --- a/libcrystfel/src/cell.c +++ b/libcrystfel/src/cell.c @@ -783,18 +783,28 @@ UnitCell *match_cell(UnitCell *cell, UnitCell *template, int verbose, continue; } - cand[i][ncand[i]].vec.u = tx; - cand[i][ncand[i]].vec.v = ty; - cand[i][ncand[i]].vec.w = tz; - cand[i][ncand[i]].na = n1; - cand[i][ncand[i]].nb = n2; - cand[i][ncand[i]].nc = n3; - cand[i][ncand[i]].fom = fabs(lengths[i] - tlen); if ( ncand[i] == MAX_CAND ) { - ERROR("Too many candidates\n"); + ERROR("Too many cell candidates - "); + ERROR("consider tightening the unit "); + ERROR("cell tolerances.\n"); } else { + + double fom; + + fom = fabs(lengths[i] - tlen); + + cand[i][ncand[i]].vec.u = tx; + cand[i][ncand[i]].vec.v = ty; + cand[i][ncand[i]].vec.w = tz; + cand[i][ncand[i]].na = n1; + cand[i][ncand[i]].nb = n2; + cand[i][ncand[i]].nc = n3; + cand[i][ncand[i]].fom = fom; + ncand[i]++; + } + } } -- cgit v1.2.3