From 5c392bc230df0cf17624d7d82ad9a6e96c37311f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 18 Mar 2020 14:34:31 +0100 Subject: Catch some error conditions --- libcrystfel/src/image.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libcrystfel') 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); -- cgit v1.2.3