aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/detector.h1
-rw-r--r--libcrystfel/src/events.c2
-rw-r--r--libcrystfel/src/hdf5-file.c20
-rw-r--r--src/im-sandbox.c6
4 files changed, 22 insertions, 7 deletions
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h
index 3fa3c141..e99fb7fc 100644
--- a/libcrystfel/src/detector.h
+++ b/libcrystfel/src/detector.h
@@ -43,6 +43,7 @@ struct panel;
struct badregion;
struct detector;
struct hdfile;
+struct event;
#include "hdf5-file.h"
#include "image.h"
diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c
index 87c0530d..a6bf9f60 100644
--- a/libcrystfel/src/events.c
+++ b/libcrystfel/src/events.c
@@ -536,7 +536,7 @@ char *event_path_placeholder_subst(const char * entry,
char *full_path;
int len_head, len_tail;
- full_path = malloc(strlen(data) + strlen(entry));
+ full_path = malloc((strlen(data) + strlen(entry)+1)*sizeof(char));
ph_loc = strstr(data, "%");
len_head = ph_loc-data;
len_tail = strlen(ph_loc);
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index df37e77f..c56ad1c6 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -36,6 +36,7 @@
#include <stdint.h>
#include <hdf5.h>
#include <assert.h>
+#include <unistd.h>
#include "events.h"
#include "image.h"
@@ -104,6 +105,12 @@ struct hdfile *hdfile_open(const char *filename)
f = malloc(sizeof(struct hdfile));
if ( f == NULL ) return NULL;
+ if ( access( filename, R_OK ) == -1 ) {
+ ERROR("File does not exists or it cannot be read: %s\n", filename);
+ free(f);
+ return NULL;
+ }
+
f->fh = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT);
if ( f->fh < 0 ) {
ERROR("Couldn't open file: %s\n", filename);
@@ -119,8 +126,8 @@ struct hdfile *hdfile_open(const char *filename)
int hdfile_set_image(struct hdfile *f, const char *path,
struct panel *p)
{
- hsize_t size[2];
- hsize_t max_size[2];
+ hsize_t *size;
+ hsize_t *max_size;
hid_t sh;
int sh_dim;
int di;
@@ -150,6 +157,9 @@ int hdfile_set_image(struct hdfile *f, const char *path,
}
+ size = malloc(sh_dim*sizeof(hsize_t));
+ max_size = malloc(sh_dim*sizeof(hsize_t));
+
H5Sget_simple_extent_dims(sh, size, max_size);
H5Sclose(sh);
@@ -173,6 +183,9 @@ int hdfile_set_image(struct hdfile *f, const char *path,
}
+ free(size);
+ free(max_size);
+
return 0;
}
@@ -1020,6 +1033,7 @@ int hdf5_read2(struct hdfile *f, struct image *image,
}
fail = hdfile_set_image(f, panel_full_path, p);
+
free(panel_full_path);
} else {
@@ -2031,7 +2045,7 @@ static herr_t parse_file_event_structure(hid_t loc_id, char *name,
truncated_path,
H5_INDEX_NAME,
H5_ITER_NATIVE, NULL,
- parse_file_event_structure,
+ (H5L_iterate_t)parse_file_event_structure,
(void *) pp, H5P_DEFAULT);
}
}
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 48518b82..e7a6e283 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -310,12 +310,12 @@ static int read_fpe_data(struct buffer_data *bd)
/* Now the block's been parsed, it should be
* forgotten about */
memmove(bd->rbuffer,
- bd->rbuffer + line_end + 2,
- bd->rbuflen - line_end - 2);
+ bd->rbuffer + line_end + 1,
+ bd->rbuflen - line_end - 1);
/* Subtract the number of bytes removed */
bd->rbufpos = bd->rbufpos - line_end - 1;
- new_rbuflen = bd->rbuflen - line_end - 2 ;
+ new_rbuflen = bd->rbuflen - line_end - 1 ;
if ( new_rbuflen == 0 ) new_rbuflen = 256;
bd->rbuffer = realloc(bd->rbuffer, new_rbuflen*sizeof(char));
bd->rbuflen = new_rbuflen;