aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2022-05-06 12:01:21 +0200
committerThomas White <taw@physics.org>2022-06-02 12:15:38 +0200
commitb0bf26431f5e4fb6bb2cb5ae3501fd57a10d15c2 (patch)
treee7fae0438b88d150fd3e9d40a3f1b37d1de7658a
parentffd98b770d6dfa7c1bef4b2ae54e0b637f2e7ac3 (diff)
Fix horrific Seedee memory leak
-rw-r--r--libcrystfel/src/image-seedee.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libcrystfel/src/image-seedee.c b/libcrystfel/src/image-seedee.c
index 1965aefa..537fc9e3 100644
--- a/libcrystfel/src/image-seedee.c
+++ b/libcrystfel/src/image-seedee.c
@@ -135,12 +135,16 @@ int image_seedee_read(struct image *image,
array.shape = malloc(array.ndims*sizeof(int));
if ( (array.data == NULL) || (array.shape == NULL) ) {
cJSON_Delete(json);
+ free(array.data);
+ free(array.shape);
return 1;
}
if ( array.ndims != 2 ) {
ERROR("Seedee data has unexpected number of dimensions "
"(%i, expected 2)\n", array.ndims);
+ free(array.data);
+ free(array.shape);
return 1;
}
@@ -152,12 +156,16 @@ int image_seedee_read(struct image *image,
cJSON_Delete(json);
if ( r < 0 ) {
ERROR("Seedee deserialiation failed.\n");
+ free(array.data);
+ free(array.shape);
return 1;
}
image->dp = malloc(dtempl->n_panels*sizeof(float *));
if ( image->dp == NULL ) {
ERROR("Failed to allocate data array.\n");
+ free(array.data);
+ free(array.shape);
return 1;
}
@@ -171,11 +179,16 @@ int image_seedee_read(struct image *image,
ERROR("Failed to load data for panel '%s'\n",
dtempl->panels[i].name);
profile_end("seedee-panel");
+ free(array.data);
+ free(array.shape);
return 1;
}
}
profile_end("seedee-panel");
+ free(array.data);
+ free(array.shape);
+
return 0;
}