From 339e02b22b51cb344d4aea26fe86281f9dbe6322 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 28 Jan 2019 14:37:09 +0100 Subject: partialator: Catch failure to set up post-refinement minimiser --- src/post-refinement.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/post-refinement.c') diff --git a/src/post-refinement.c b/src/post-refinement.c index fd0d5c4e..7c388f8d 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -620,7 +620,15 @@ static gsl_multimin_fminimizer *setup_minimiser(Crystal *cr, const RefList *full min = gsl_multimin_fminimizer_alloc(gsl_multimin_fminimizer_nmsimplex2, n_params); - gsl_multimin_fminimizer_set(min, &priv->f, priv->vals, priv->step); + if ( min == NULL ) { + ERROR("Failed to allocate minimiser\n"); + return NULL; + } + + if ( gsl_multimin_fminimizer_set(min, &priv->f, priv->vals, priv->step) ) { + ERROR("Failed to set up minimiser\n"); + return NULL; + } return min; } @@ -734,6 +742,7 @@ static void do_pr_refine(Crystal *cr, const RefList *full, } min = setup_minimiser(cr, full, verbose, serial, scaleflags, &priv); + if ( min == NULL ) return; if ( verbose ) { double res = residual_f(min->x, &priv); -- cgit v1.2.3