aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/image-hdf5.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c
index 129fb62c..8ec76ee6 100644
--- a/libcrystfel/src/image-hdf5.c
+++ b/libcrystfel/src/image-hdf5.c
@@ -1153,7 +1153,8 @@ static int read_peak_count(hid_t fh, char *path, int line,
}
-static float *read_peak_line(hid_t fh, char *path, int line)
+static float *read_peak_line(hid_t fh, char *path, int line,
+ int num_peaks)
{
hid_t dh, sh, mh;
@@ -1196,6 +1197,15 @@ static float *read_peak_line(hid_t fh, char *path, int line)
return NULL;
}
+ /* NB The array might be bigger - Cheetah allocates in blocks of 2048 */
+ if ( size[1] < num_peaks ) {
+ ERROR("Data block %s is too small for the specified number of "
+ "peaks (has %i, expected %i)\n", path, size[1], num_peaks);
+ H5Sclose(sh);
+ H5Dclose(dh);
+ return NULL;
+ }
+
offset[0] = line;
offset[1] = 0;
count[0] = 1;
@@ -1315,19 +1325,19 @@ ImageFeatureList *image_hdf5_read_peaks_cxi(const DataTemplate *dtempl,
return NULL;
}
- buf_x = read_peak_line(fh, path_x, line);
+ buf_x = read_peak_line(fh, path_x, line, num_peaks);
if ( buf_x == NULL ) {
close_hdf5(fh);
return NULL;
}
- buf_y = read_peak_line(fh, path_y, line);
+ buf_y = read_peak_line(fh, path_y, line, num_peaks);
if ( buf_y == NULL ) {
close_hdf5(fh);
return NULL;
}
- buf_i = read_peak_line(fh, path_i, line);
+ buf_i = read_peak_line(fh, path_i, line, num_peaks);
if ( buf_i == NULL ) {
close_hdf5(fh);
return NULL;