From 17d688c12c3b6770d9e2fab08b9216653677301e Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Wed, 31 Aug 2022 19:09:58 +0200
Subject: [PATCH] Fix coverity issue 1516479 Resource leak

---
 testing/testing_zgepdf_qdwh.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/testing/testing_zgepdf_qdwh.c b/testing/testing_zgepdf_qdwh.c
index 17cb18a4a..d573d723e 100644
--- a/testing/testing_zgepdf_qdwh.c
+++ b/testing/testing_zgepdf_qdwh.c
@@ -86,9 +86,9 @@ testing_zgepdf_qdwh_desc( run_arg_list_t *args, int check )
     if ( hres != 0 ) {
         return hres;
     }
-    /* 
-     * descA0 is defined here because of the cost of zlatms. To copy descA in descA0 
-     * now prevents to call it again later in the check (indeed descA is modified 
+    /*
+     * descA0 is defined here because of the cost of zlatms. To copy descA in descA0
+     * now prevents to call it again later in the check (indeed descA is modified
      * with the call to CHAMELEON_zgepdf_qdwh_Tile[_Async]).
      */
     if ( check ) {
@@ -167,12 +167,14 @@ testing_zgepdf_qdwh_std( run_arg_list_t *args, int check )
     /* Fills the matrix with random values */
     hres = CHAMELEON_zlatms( M, N, ChamDistUniform, seedA, ChamNonsymPosv, NULL, mode, cond, 1., A, LDA );
     if ( hres != 0 ) {
+        free( A );
+        free( H );
         return hres;
     }
-    /* 
-     * A0 is defined here because of the cost of zlatms. To copy A in A0 
-     * now prevents to call it again later in the check (indeed A is modified 
-     * with the call to CHAMELEON_zgepdf_qdwh). 
+    /*
+     * A0 is defined here because of the cost of zlatms. To copy A in A0
+     * now prevents to call it again later in the check (indeed A is modified
+     * with the call to CHAMELEON_zgepdf_qdwh).
      */
     if ( check ) {
         A0 = malloc( LDA*N*sizeof(CHAMELEON_Complex64_t) );
-- 
GitLab