diff options
author | Thomas White <taw@physics.org> | 2021-07-21 11:51:56 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-07-21 15:34:31 +0200 |
commit | 6d94d4115c254d344bbb927596a7141ef39fd298 (patch) | |
tree | 652d07c4d6a9521c9359aa13bbda27309f53e6f8 /libcrystfel/src/image-cbf.c | |
parent | 50cf52b0bc0baa683b9508568131a3f6281bf4ff (diff) |
Add missing cleanup on error paths
Diffstat (limited to 'libcrystfel/src/image-cbf.c')
-rw-r--r-- | libcrystfel/src/image-cbf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libcrystfel/src/image-cbf.c b/libcrystfel/src/image-cbf.c index 859ef731..1e5659f4 100644 --- a/libcrystfel/src/image-cbf.c +++ b/libcrystfel/src/image-cbf.c @@ -314,7 +314,10 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h) } while ( len_read == bufinc ); fh = fmemopen(buf, len, "rb"); - if ( fh == NULL ) return NULL; + if ( fh == NULL ) { + free(buf); + return NULL; + } gzclose(gzfh); @@ -507,7 +510,11 @@ signed int is_cbf_file(const char *filename) fh = fopen(filename, "r"); if ( fh == NULL ) return -1; - if ( fgets(line, 1024, fh) == NULL ) return 0; + if ( fgets(line, 1024, fh) == NULL ) { + fclose(fh); + return 0; + } + fclose(fh); if ( strstr(line, "CBF") == NULL ) { |