From 029f91509a172ea4d50259451044c48e453192ae Mon Sep 17 00:00:00 2001
From: ulfvonbelow <striness@tilde.club>
Date: Thu, 2 May 2024 21:51:09 -0500
Subject: [PATCH] gnsrecord: fix memory leak in test_gnsrecord_testvectors

---
 src/lib/gnsrecord/test_gnsrecord_testvectors.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/lib/gnsrecord/test_gnsrecord_testvectors.c b/src/lib/gnsrecord/test_gnsrecord_testvectors.c
index 21a7a83b0..4b171b165 100644
--- a/src/lib/gnsrecord/test_gnsrecord_testvectors.c
+++ b/src/lib/gnsrecord/test_gnsrecord_testvectors.c
@@ -655,6 +655,7 @@ main ()
       printf ("FAIL: query does not match:");
       printf ("  expected: %s", GNUNET_h2s (&expected_query));
       printf (", was: %s\n", GNUNET_h2s (&query));
+      GNUNET_free (rrblock);
       res = 1;
       break;
     }
@@ -671,6 +672,7 @@ main ()
     {
       printf ("FAIL: Deserialization of RDATA failed\n");
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     expire = GNUNET_GNSRECORD_record_get_expiration_time (
@@ -681,6 +683,7 @@ main ()
         (GNUNET_OK != check_derivations_pkey (label, expire, &pub, &tvs[i])))
     {
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     else if ((GNUNET_GNSRECORD_TYPE_EDKEY == ntohl (pub.type)) &&
@@ -688,6 +691,7 @@ main ()
                                                     &tvs[i])))
     {
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     if (GNUNET_OK != GNUNET_GNSRECORD_block_decrypt (rrblock,
@@ -698,10 +702,15 @@ main ()
     {
       printf ("FAIL: Decryption of RRBLOCK failed\n");
       res = 1;
+      GNUNET_free (rrblock);
       break;
     }
     if (0 != res)
+    {
+      GNUNET_free (rrblock);
       break;
+    }
+    GNUNET_free (rrblock);
     printf ("Good.\n");
   }
   return res;
-- 
2.41.0

