diff options
author | Thomas White <taw@physics.org> | 2013-05-27 14:45:43 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2013-05-27 17:33:16 +0200 |
commit | c1c9625a8db520c685abffb886d5a43316086092 (patch) | |
tree | bd3cb5551bdc5891cee66568343712a65cb6caba | |
parent | 28f7058a9608b119b5103da65a1939ee5b2f264c (diff) |
hdfsee: Fix segfault on startup
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 12b6dab2..bd0a3e37 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -620,31 +620,42 @@ int hdf5_read(struct hdfile *f, struct image *image, int satcorr) if ( satcorr ) debodge_saturation(f, image); - if ( (image->width != image->det->max_fs + 1 ) - || (image->height != image->det->max_ss + 1)) - { - ERROR("Image size doesn't match geometry size" - " - rejecting image.\n"); - ERROR("Image size: %i,%i. Geometry size: %i,%i\n", - image->width, image->height, - image->det->max_fs + 1, image->det->max_ss + 1); - return 1; - } + if ( image->det != NULL ) { + + if ( (image->width != image->det->max_fs + 1 ) + || (image->height != image->det->max_ss + 1)) + { + ERROR("Image size doesn't match geometry size" + " - rejecting image.\n"); + ERROR("Image size: %i,%i. Geometry size: %i,%i\n", + image->width, image->height, + image->det->max_fs + 1, image->det->max_ss + 1); + return 1; + } - fill_in_values(image->det, f); - fill_in_beam_parameters(image->beam, f); - image->lambda = ph_en_to_lambda(eV_to_J(image->beam->photon_energy)); + fill_in_values(image->det, f); + + unpack_panels(image, image->det); - if ( (image->beam->photon_energy < 0.0) || (image->lambda > 1000) ) { - /* Error message covers a silly value in the beam file or in - * the HDF5 file. */ - ERROR("Nonsensical wavelength (%e m or %e eV) value for %s.\n", - image->lambda, image->beam->photon_energy, - image->filename); - return 1; } - unpack_panels(image, image->det); + if ( image->beam != NULL ) { + + fill_in_beam_parameters(image->beam, f); + image->lambda = ph_en_to_lambda(eV_to_J(image->beam->photon_energy)); + + if ( (image->beam->photon_energy < 0.0) + || (image->lambda > 1000) ) { + /* Error message covers a silly value in the beam file + * or in the HDF5 file. */ + ERROR("Nonsensical wavelength (%e m or %e eV) value " + "for %s.\n", + image->lambda, image->beam->photon_energy, + image->filename); + return 1; + } + + } return 0; } |