From 0141473aa4020840c1faa91ec1933f8588520545 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 14 Jan 2024 15:12:03 +0100 Subject: [PATCH] Don't derefence Matrix->SMPkluMatrix->KLUmatrixCommon if it is NULL. Test for NULL moved upwards in front of dereferencing. --- src/maths/KLU/klusmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/maths/KLU/klusmp.c b/src/maths/KLU/klusmp.c index 174dee419..d22c36f94 100644 --- a/src/maths/KLU/klusmp.c +++ b/src/maths/KLU/klusmp.c @@ -535,6 +535,10 @@ SMPcLUfac (SMPmatrix *Matrix, double PivTol) if (ret == 0) { + if (Matrix->SMPkluMatrix->KLUmatrixCommon == NULL) { + fprintf(stderr, "Error (ReFactor Complex): KLUcommon object is NULL. A problem occurred\n"); + return 0 ; + } if (Matrix->SMPkluMatrix->KLUmatrixCommon->status == KLU_SINGULAR) { if (ft_ngdebug) { fprintf(stderr, "Warning (ReFactor Complex): KLU Matrix is SINGULAR\n"); @@ -543,9 +547,6 @@ SMPcLUfac (SMPmatrix *Matrix, double PivTol) } return E_SINGULAR ; } - if (Matrix->SMPkluMatrix->KLUmatrixCommon == NULL) { - fprintf (stderr, "Error (ReFactor Complex): KLUcommon object is NULL. A problem occurred\n") ; - } if (Matrix->SMPkluMatrix->KLUmatrixCommon->status == KLU_EMPTY_MATRIX) { fprintf (stderr, "Error (ReFactor Complex): KLU Matrix is empty\n") ;