From 78f369eb0ce0a03cc526db749e5ac3d93d83a806 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 23 Jul 2021 13:17:39 +0200 Subject: TakeTwo: Avoid potential NULL dereference on error path --- libcrystfel/src/indexers/taketwo.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/libcrystfel/src/indexers/taketwo.c b/libcrystfel/src/indexers/taketwo.c index 29598a01..68b2897c 100644 --- a/libcrystfel/src/indexers/taketwo.c +++ b/libcrystfel/src/indexers/taketwo.c @@ -849,17 +849,18 @@ static int obs_vecs_match_angles(int her, int his, if ( tmp_seeds == NULL ) { apologise(); - } + } else { - (*seeds) = tmp_seeds; + (*seeds) = tmp_seeds; - (*seeds)[*match_count].obs1 = her; - (*seeds)[*match_count].obs2 = his; - (*seeds)[*match_count].idx1 = i; - (*seeds)[*match_count].idx2 = j; - (*seeds)[*match_count].score = score * 1000; + (*seeds)[*match_count].obs1 = her; + (*seeds)[*match_count].obs2 = his; + (*seeds)[*match_count].idx1 = i; + (*seeds)[*match_count].idx2 = j; + (*seeds)[*match_count].score = score * 1000; - (*match_count)++; + (*match_count)++; + } } } @@ -2071,16 +2072,17 @@ static UnitCell *run_taketwo(UnitCell *cell, const struct taketwo_options *opts, if (!tmp) { apologise(); - } + } else { - tp->prevSols = tmp; - tp->prevScores = tmpScores; - tp->membership = tmpSuccesses; + tp->prevSols = tmp; + tp->prevScores = tmpScores; + tp->membership = tmpSuccesses; - tp->prevSols[tp->numPrevs] = solution; - tp->prevScores[tp->numPrevs] = score; - tp->membership[tp->numPrevs] = members; - tp->numPrevs++; + tp->prevSols[tp->numPrevs] = solution; + tp->prevScores[tp->numPrevs] = score; + tp->membership[tp->numPrevs] = members; + tp->numPrevs++; + } /* Prepare the solution for CrystFEL friendliness */ result = cell_post_smiley_face(cell, solution); -- cgit v1.2.3