Skip to content

Commit 0689981

Browse files
committed
fix a couple of minor leaks
1 parent 3a006bf commit 0689981

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

eidos/eidos_functions_matrices.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,8 @@ EidosValue_SP Eidos_ExecuteFunction_inverse(const std::vector<EidosValue_SP> &p_
14661466
if (result != GSL_SUCCESS)
14671467
{
14681468
// This indicates that the matrix is singular, and the determinant is zero; for inverse() this is an error
1469+
gsl_matrix_free(A);
1470+
gsl_permutation_free(p);
14691471
EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_inverse): in function inverse() x must not be singular (i.e., must be invertible). You can use det() to check for singularity prior to calling inverse()." << EidosTerminate(nullptr);
14701472
}
14711473

@@ -1482,11 +1484,17 @@ EidosValue_SP Eidos_ExecuteFunction_inverse(const std::vector<EidosValue_SP> &p_
14821484
if (result == GSL_EDOM)
14831485
{
14841486
// This indicates that the matrix is singular, and the determinant is zero; for inverse() this is an error
1487+
gsl_matrix_free(A);
1488+
gsl_permutation_free(p);
1489+
gsl_matrix_free(inverse);
14851490
EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_inverse): in function inverse() x must not be singular (i.e., must be invertible). You can use det() to check for singularity prior to calling inverse()." << EidosTerminate(nullptr);
14861491
}
14871492
else if (result != GSL_SUCCESS)
14881493
{
14891494
// Some other error occurred
1495+
gsl_matrix_free(A);
1496+
gsl_permutation_free(p);
1497+
gsl_matrix_free(inverse);
14901498
EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_inverse): in function inverse() an internal GSL error occurred (code == " << result << ")." << EidosTerminate(nullptr);
14911499
}
14921500

0 commit comments

Comments
 (0)