aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/xds.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-10-07 10:37:19 +0200
committerThomas White <taw@physics.org>2016-10-07 10:37:19 +0200
commit3f44edf747454fedbe8b990cb4b19ccce715d5ef (patch)
treeade77233181021d1325ffc0b50692e7ac5b16bf1 /libcrystfel/src/xds.c
parent44c3496f9bbd908e43583d3d2d6d79ee11a8528c (diff)
XDS: Clean up open files
Diffstat (limited to 'libcrystfel/src/xds.c')
-rw-r--r--libcrystfel/src/xds.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libcrystfel/src/xds.c b/libcrystfel/src/xds.c
index eff2c85a..15826760 100644
--- a/libcrystfel/src/xds.c
+++ b/libcrystfel/src/xds.c
@@ -247,29 +247,42 @@ static int read_cell(struct image *image, struct xds_private *xp)
do {
rval = fgets(line, 1023, fh);
- if ( rval == NULL ) return 0;
+ if ( rval == NULL ) {
+ fclose(fh);
+ return 0;
+ }
} while ( strcmp(line, " # COORDINATES OF REC. BASIS VECTOR"
" LENGTH 1/LENGTH\n") != 0 );
/* Free line after chunk */
rval = fgets(line, 1023, fh);
- if ( rval == NULL ) return 0;
+ if ( rval == NULL ) {
+ fclose(fh);
+ return 0;
+ }
rval = fgets(line, 1023, fh);
- if ( rval == NULL ) return 0;
+ if ( rval == NULL ) {
+ fclose(fh);
+ return 0;
+ }
memcpy(asx, line+7, 10); asx[10] = '\0';
memcpy(asy, line+17, 10); asy[10] = '\0';
memcpy(asz, line+27, 10); asz[10] = '\0';
rval = fgets(line, 1023, fh);
- if ( rval == NULL ) return 0;
+ if ( rval == NULL ) {
+ fclose(fh);
+ return 0;
+ }
memcpy(bsx, line+7, 10); bsx[10] = '\0';
memcpy(bsy, line+17, 10); bsy[10] = '\0';
memcpy(bsz, line+27, 10); bsz[10] = '\0';
rval = fgets(line, 1023, fh);
+ fclose(fh);
if ( rval == NULL ) return 0;
memcpy(csx, line+7, 10); csx[10] = '\0';
@@ -291,8 +304,6 @@ static int read_cell(struct image *image, struct xds_private *xp)
return 0;
}
- fclose(fh);
-
cell = cell_new();
cell_set_reciprocal(cell,
axstar*10e9, aystar*10e9, azstar*10e9,