aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/datatemplate.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-02-15 11:39:18 +0100
committerThomas White <taw@physics.org>2021-02-15 11:39:18 +0100
commit09e71ff37379f6827a50a0e2d4ec26971af2b00c (patch)
treecb1a38658554f99a0aa117cc050fe7cca6decb37 /libcrystfel/src/datatemplate.c
parent82e6750fd53bf0bea4bd665edb60cc244ce923ce (diff)
Check that bad regions are actually within panel bounds
Diffstat (limited to 'libcrystfel/src/datatemplate.c')
-rw-r--r--libcrystfel/src/datatemplate.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index b92fcb0a..6712c280 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -1285,11 +1285,31 @@ DataTemplate *data_template_new_from_string(const char *string_in)
reject = 1;
} else {
struct panel_template *p;
+ struct dt_badregion *bad;
+ int r = 0;
p = &dt->panels[dt->bad[i].panel_number];
- dt->bad[i].min_fs -= p->orig_min_fs;
- dt->bad[i].max_fs -= p->orig_min_fs;
- dt->bad[i].min_ss -= p->orig_min_ss;
- dt->bad[i].max_ss -= p->orig_min_ss;
+ bad = &dt->bad[i];
+ if ( bad->min_fs < p->orig_min_fs ) r = 1;
+ if ( bad->min_ss < p->orig_min_ss ) r = 1;
+ if ( bad->max_fs > p->orig_max_fs ) r = 1;
+ if ( bad->max_ss > p->orig_max_ss ) r = 1;
+ if ( r ) {
+ ERROR("Bad region '%s' is outside the "
+ "panel bounds (%s) as presented "
+ "in data (%i %i, %i %i inclusive): "
+ "Bad region %i,%i to %i, %i "
+ "inclusive\n",
+ bad->name, p->name,
+ p->orig_min_fs, p->orig_min_ss,
+ p->orig_max_fs, p->orig_max_ss,
+ bad->min_fs, bad->min_ss,
+ bad->max_fs, bad->max_ss);
+ reject = 1;
+ }
+ bad->min_fs -= p->orig_min_fs;
+ bad->max_fs -= p->orig_min_fs;
+ bad->min_ss -= p->orig_min_ss;
+ bad->max_ss -= p->orig_min_ss;
}
}
}