diff options
author | Thomas White <taw@physics.org> | 2021-07-23 13:17:39 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2021-07-23 13:17:39 +0200 |
commit | 78f369eb0ce0a03cc526db749e5ac3d93d83a806 (patch) | |
tree | 7a0deb855e4394c17a7ed1164ffcae78fbaeb6fe /libcrystfel/src | |
parent | 91ae9e7c30ffea89ae57fe7107958d8634d829ba (diff) |
TakeTwo: Avoid potential NULL dereference on error path
Diffstat (limited to 'libcrystfel/src')
-rw-r--r-- | libcrystfel/src/indexers/taketwo.c | 34 |
1 files 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); |