From 639b9c29b7270a96042b5a175822dd060dea412a Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Wed, 18 Sep 2024 13:36:57 +0100 Subject: [PATCH] Ensure rowbasis and colbasis are freed. --- cython/pycddlib.pxi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cython/pycddlib.pxi b/cython/pycddlib.pxi index c044f4a..a88a60b 100644 --- a/cython/pycddlib.pxi +++ b/cython/pycddlib.pxi @@ -419,9 +419,11 @@ def matrix_rank( rank = dd_MatrixRank( mat.dd_mat, dd_ignored_rows, dd_ignored_cols, &rowbasis, &colbasis ) - result = (_get_set(rowbasis), _get_set(colbasis), rank) - set_free(rowbasis) - set_free(colbasis) + try: + result = (_get_set(rowbasis), _get_set(colbasis), rank) + finally: + set_free(rowbasis) + set_free(colbasis) finally: set_free(dd_ignored_cols) finally: