From 025f9e9c9022bb1118783a089fa5854b956eb04a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 22 Sep 2022 14:42:01 +0200 Subject: all_panels_reference_same_clen: Handle missing units --- libcrystfel/src/datatemplate.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c index 1075b349..bbcf1aa5 100644 --- a/libcrystfel/src/datatemplate.c +++ b/libcrystfel/src/datatemplate.c @@ -1853,6 +1853,14 @@ static int im_get_length(struct image *image, const char *from, } +static int safe_strcmp(const char *a, const char *b) +{ + if ( (a==NULL) && (b==NULL) ) return 0; + if ( (a!=NULL) && (b!=NULL) ) return strcmp(a, b); + return 1; +} + + static int all_panels_reference_same_clen(const DataTemplate *dtempl) { int i; @@ -1872,8 +1880,8 @@ static int all_panels_reference_same_clen(const DataTemplate *dtempl) first_val = val; first_units = units; } else { - if ( strcmp(val, first_val) != 0 ) fail = 1; - if ( strcmp(units, first_units) != 0 ) fail = 1; + if ( safe_strcmp(val, first_val) != 0 ) fail = 1; + if ( safe_strcmp(units, first_units) != 0 ) fail = 1; free(val); free(units); } -- cgit v1.2.3