aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-06-22 17:30:06 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:28 +0100
commit2cb199e1062b3bba2f029eb8a0c5a51b9c4df2da (patch)
treea4afee50b5894a1061a4e420841e67799e0bba7d /src
parentbcc00985f499261aed26511b5b5d55aa833cb3dd (diff)
Safeguard against silly unit cells in find_intersections()
Diffstat (limited to 'src')
-rw-r--r--src/geometry.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/geometry.c b/src/geometry.c
index 440f7698..253456b7 100644
--- a/src/geometry.c
+++ b/src/geometry.c
@@ -257,6 +257,14 @@ RefList *find_intersections(struct image *image, UnitCell *cell,
kmax = mres / modulus(bsx, bsy, bsz);
lmax = mres / modulus(csx, csy, csz);
+ if ( (hmax >= 256) || (kmax >= 256) || (lmax >= 256) ) {
+ ERROR("Unit cell is stupidly large.\n");
+ cell_print(cell);
+ if ( hmax >= 256 ) hmax = 255;
+ if ( kmax >= 256 ) kmax = 255;
+ if ( lmax >= 256 ) lmax = 255;
+ }
+
for ( h=-hmax; h<=hmax; h++ ) {
for ( k=-kmax; k<=kmax; k++ ) {
for ( l=-lmax; l<=lmax; l++ ) {