aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-03-18 14:34:31 +0100
committerThomas White <taw@physics.org>2020-07-29 18:42:57 +0200
commit5c392bc230df0cf17624d7d82ad9a6e96c37311f (patch)
treeb8f3e9d594c5f06fb58750cc05bb624dae0cb599 /libcrystfel
parent6f73806c31df5f8b9a48a575a4dafd01e896adce (diff)
Catch some error conditions
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 0208eb83..0e820224 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -1842,6 +1842,8 @@ static double get_value(struct image *image, const char *from)
double val;
char *rval;
+ if ( from == NULL ) return NAN;
+
val = strtod(from, &rval);
if ( *rval == '\0' ) return val;
@@ -1866,6 +1868,11 @@ static void create_detgeom(struct image *image, DataTemplate *dtempl)
struct detgeom *detgeom;
int i;
+ if ( dtempl == NULL ) {
+ ERROR("NULL data template!\n");
+ return;
+ }
+
detgeom = malloc(sizeof(struct detgeom));
if ( detgeom == NULL ) return;
@@ -1912,6 +1919,11 @@ struct image *image_read(DataTemplate *dtempl, const char *filename,
{
struct image *image;
+ if ( dtempl == NULL ) {
+ ERROR("NULL data template!\n");
+ return NULL;
+ }
+
if ( H5Fis_hdf5(filename) > 0 ) {
image = image_read_hdf5(dtempl, filename, event);