aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/peaks.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2012-07-11 22:54:53 +0200
committerThomas White <taw@bitwiz.org.uk>2012-07-11 22:54:53 +0200
commit849df8b6dd7de1d45eaf8af1f4f2b1c1d72e5c9c (patch)
tree641d3211bc42fd0ce2ab8c6009f9eff0e76f76b8 /libcrystfel/src/peaks.c
parent0fe6353366b4175b63739f5da63c1cef2c2b74dd (diff)
Fix a load of memory leaks
Diffstat (limited to 'libcrystfel/src/peaks.c')
-rw-r--r--libcrystfel/src/peaks.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index ffe77290..047bac34 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -160,6 +160,8 @@ static int *make_BgMask(struct image *image, struct panel *p,
mask = calloc(w*h, sizeof(int));
if ( mask == NULL ) return NULL;
+ if ( image->reflections == NULL ) return mask;
+
/* Loop over all reflections */
for ( refl = first_refl(image->reflections, &iter);
refl != NULL;
@@ -278,17 +280,26 @@ static int integrate_peak(struct image *image, int cfs, int css,
/* It must have all the "good" bits to be valid */
if ( !((flags & image->det->mask_good)
- == image->det->mask_good) ) return 1;
+ == image->det->mask_good) ) {
+ free(bgPkMask);
+ return 1;
+ }
/* If it has any of the "bad" bits, reject */
- if ( flags & image->det->mask_bad ) return 1;
+ if ( flags & image->det->mask_bad ) {
+ free(bgPkMask);
+ return 1;
+ }
}
val = image->data[idx];
/* Veto peak if it contains saturation in bg region */
- if ( use_max_adu && (val > p->max_adu) ) return 1;
+ if ( use_max_adu && (val > p->max_adu) ) {
+ free(bgPkMask);
+ return 1;
+ }
bg_tot += val;
bg_tot_sq += pow(val, 2.0);
@@ -330,17 +341,26 @@ static int integrate_peak(struct image *image, int cfs, int css,
/* It must have all the "good" bits to be valid */
if ( !((flags & image->det->mask_good)
- == image->det->mask_good) ) return 1;
+ == image->det->mask_good) ) {
+ free(bgPkMask);
+ return 1;
+ }
/* If it has any of the "bad" bits, reject */
- if ( flags & image->det->mask_bad ) return 1;
+ if ( flags & image->det->mask_bad ) {
+ free(bgPkMask);
+ return 1;
+ }
}
val = image->data[idx] - bg_mean;
/* Veto peak if it contains saturation */
- if ( use_max_adu && (image->data[idx] > p->max_adu) ) return 1;
+ if ( use_max_adu && (image->data[idx] > p->max_adu) ) {
+ free(bgPkMask);
+ return 1;
+ }
pk_counts++;
pk_total += val;