From 628e263dce6ca70b06c60904d4de568b87a833f7 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 3 Sep 2019 15:27:15 +0200 Subject: Fix memory leaks in cell comparison --- libcrystfel/src/cell-utils.c | 4 ++++ libcrystfel/src/index.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c index c59d7f96..0365b426 100644 --- a/libcrystfel/src/cell-utils.c +++ b/libcrystfel/src/cell-utils.c @@ -2152,6 +2152,8 @@ static IntegerMatrix *check_permutations(UnitCell *cell_reduced, UnitCell *refer } } + intmat_free(m); + if ( n_best == 0 ) return NULL; sel = n_best; @@ -2309,7 +2311,9 @@ UnitCell *compare_reindexed_cell_parameters(UnitCell *cell_in, match = NULL; } + rtnl_mtx_free(CiARA); rtnl_mtx_free(CiA); + intmat_free(RiBCB); intmat_free(RA); intmat_free(RB); intmat_free(CB); diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index af4385cd..36d7b84b 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -539,10 +539,10 @@ static int check_cell(IndexingFlags flags, Crystal *cr, UnitCell *target, /* Check at all? */ if ( !(flags & INDEXING_CHECK_CELL) ) return 0; - if ( compare_reindexed_cell_parameters(crystal_get_cell(cr), target, - tolerance, &rm) ) - { - out = cell_transform_rational(crystal_get_cell(cr), rm); + out = compare_reindexed_cell_parameters(crystal_get_cell(cr), target, + tolerance, &rm); + + if ( out != NULL ) { cell_free(crystal_get_cell(cr)); crystal_set_cell(cr, out); rtnl_mtx_free(rm); -- cgit v1.2.3