aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-02-28 15:58:25 +0100
committerThomas White <taw@physics.org>2019-03-01 14:09:37 +0100
commit2ef84f8419beee133ba72d7c74966b83d3e6471d (patch)
treef10a3aa954b919d81eac4362e287959ce8083f88 /src
parentb5f0141aa339b3af4761f155ccd05308b6db05b5 (diff)
partialator: Avoid double-free of stuff_from_stream and filename
Diffstat (limited to 'src')
-rw-r--r--src/partialator.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/partialator.c b/src/partialator.c
index 50518b99..9de5276f 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -1345,6 +1345,9 @@ int main(int argc, char *argv[])
return 1;
}
+ free_stuff_from_stream(cur.stuff_from_stream);
+ cur.stuff_from_stream = NULL;
+
for ( i=0; i<cur.n_crystals; i++ ) {
Crystal *cr;
@@ -1378,7 +1381,8 @@ int main(int argc, char *argv[])
*image = cur;
image->n_crystals = 1;
image->crystals = &crystals[n_crystals];
- free(cur.crystals);
+
+ image->filename = strdup(image->filename);
/* This is the raw list of reflections */
cr_refl = crystal_get_reflections(cr);
@@ -1408,6 +1412,8 @@ int main(int argc, char *argv[])
if ( n_crystals == stop_after ) break;
}
+ free(cur.crystals);
+ free(cur.filename);
n_images++;
@@ -1575,7 +1581,6 @@ int main(int argc, char *argv[])
for ( i=0; i<n_crystals; i++ ) {
struct image *image = crystal_get_image(crystals[i]);
reflist_free(crystal_get_reflections(crystals[i]));
- free_stuff_from_stream(image->stuff_from_stream);
free(image->filename);
free(image);
cell_free(crystal_get_cell(crystals[i]));