aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/cell-utils.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2012-10-02 16:11:09 +0200
committerThomas White <taw@bitwiz.org.uk>2012-10-02 16:11:09 +0200
commit0509e8ad099a0e6755b7667b067c8c9303348ec8 (patch)
treec6fa9488bb967d99f98acdf810a9f969c11508e9 /libcrystfel/src/cell-utils.c
parent6633efd7a1931925bb6814dad0761f10d0a457b7 (diff)
Fix segfault on failed indexing
Diffstat (limited to 'libcrystfel/src/cell-utils.c')
-rw-r--r--libcrystfel/src/cell-utils.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libcrystfel/src/cell-utils.c b/libcrystfel/src/cell-utils.c
index 3aaae90e..ae06774a 100644
--- a/libcrystfel/src/cell-utils.c
+++ b/libcrystfel/src/cell-utils.c
@@ -683,13 +683,21 @@ UnitCell *match_cell(UnitCell *cell_in, UnitCell *template_in, int verbose,
free(cand[2]);
/* Reverse the de-centering transformation */
- new_cell_trans = cell_transform_inverse(new_cell, uncentering);
- cell_free(new_cell);
- cell_set_lattice_type(new_cell, cell_get_lattice_type(template_in));
- cell_set_centering(new_cell, cell_get_centering(template_in));
- cell_set_unique_axis(new_cell, cell_get_unique_axis(template_in));
+ if ( new_cell != NULL ) {
- return new_cell_trans;
+ new_cell_trans = cell_transform_inverse(new_cell, uncentering);
+ cell_free(new_cell);
+ cell_set_lattice_type(new_cell,
+ cell_get_lattice_type(template_in));
+ cell_set_centering(new_cell, cell_get_centering(template_in));
+ cell_set_unique_axis(new_cell,
+ cell_get_unique_axis(template_in));
+
+ return new_cell_trans;
+
+ } else {
+ return NULL;
+ }
}