aboutsummaryrefslogtreecommitdiff
path: root/src/detector.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2010-09-04 14:15:16 +0200
committerThomas White <taw@physics.org>2012-02-22 15:26:56 +0100
commit2c86e6ef610d8428aef151cad4e0bfc0efbfce48 (patch)
tree63582b7e05868d4886d1e0939d60be3b435afaef /src/detector.c
parentac01ef9764709b3b20c87bb6278822f4c5a3fdd3 (diff)
Detector geometry parsing fixes
Diffstat (limited to 'src/detector.c')
-rw-r--r--src/detector.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/detector.c b/src/detector.c
index 9a6ab51c..95772e4a 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -238,8 +238,29 @@ struct detector *get_detector_geometry(const char *filename)
}
n2 = assplode(bits[0], "/\\.", &path, ASSPLODE_NONE);
+ if ( n2 < 2 ) {
+ /* This was a top-level option, but not handled above. */
+ for ( i=0; i<n1; i++ ) free(bits[i]);
+ free(bits);
+ for ( i=0; i<n2; i++ ) free(path[i]);
+ free(path);
+ continue;
+ }
np = atoi(path[0]);
+ if ( det->n_panels == -1 ) {
+ ERROR("n_panels statement must come first in "
+ "detector geometry file.\n");
+ return NULL;
+ }
+
+ if ( np > det->n_panels ) {
+ ERROR("The detector geometry file said there were %i "
+ "panels, but then tried to specify number %i\n",
+ det->n_panels, np);
+ ERROR("Note: panel indices are counted from zero.\n");
+ return NULL;
+ }
if ( strcmp(path[1], "min_x") == 0 ) {
det->panels[np].min_x = atof(bits[2]);