From 2974e0096fa88f0edd79461cde5123ffcbee7ac2 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Wed, 31 Aug 2022 19:12:35 +0200
Subject: [PATCH] Fix coverity issue 1517612 Resource leak

---
 testing/testing_zgesvd.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/testing/testing_zgesvd.c b/testing/testing_zgesvd.c
index 413ca1367..0c83d183c 100644
--- a/testing/testing_zgesvd.c
+++ b/testing/testing_zgesvd.c
@@ -126,6 +126,10 @@ testing_zgesvd_desc( run_arg_list_t *args, int check )
     /* Fills the matrix with random values */
     hres = CHAMELEON_zlatms_Tile( ChamDistUniform, seedA, ChamNonsymPosv, D, mode, cond, 1., descA );
     if ( hres != 0 ) {
+        free( D );
+        free( S );
+        free( U );
+        free( Vt );
         return hres;
     }
     /*
@@ -153,7 +157,6 @@ testing_zgesvd_desc( run_arg_list_t *args, int check )
 
     /* Checks the factorisation and residue */
     if ( check ) {
-
         hres += check_zgesvd( args, jobu, jobvt, descA0, descA, D, S, U, LDU, Vt, LDVt );
         CHAMELEON_Desc_Destroy( &descA0 );
     }
@@ -162,12 +165,8 @@ testing_zgesvd_desc( run_arg_list_t *args, int check )
     CHAMELEON_Desc_Destroy( &descT );
     free( S );
     free( D );
-    if ( (jobu  == ChamAllVec) || (jobu  == ChamSVec) ) {
-        free( U );
-    }
-    if ( (jobvt == ChamAllVec) || (jobvt == ChamSVec) ) {
-        free( Vt );
-    }
+    free( U );
+    free( Vt );
 
     return hres;
 }
-- 
GitLab