[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] helper_compare_hs_desc: coverity memleak complaints



commit 8143c30a5c28a5a76a82b4b17313bf340e5a47d5
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Dec 12 08:10:05 2016 -0500

    helper_compare_hs_desc: coverity memleak complaints
    
    This test helper had a memory leak on failure, which Coverity Scan
    doesn't like.  Closes CID 1375996 and 1375997. Not in any released
    Tor.
---
 src/test/test_hs_descriptor.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c
index 9749c3b..3f588df 100644
--- a/src/test/test_hs_descriptor.c
+++ b/src/test/test_hs_descriptor.c
@@ -130,6 +130,7 @@ static void
 helper_compare_hs_desc(const hs_descriptor_t *desc1,
                        const hs_descriptor_t *desc2)
 {
+  char *addr1 = NULL, *addr2 = NULL;
   /* Plaintext data section. */
   tt_int_op(desc1->plaintext_data.version, OP_EQ,
             desc2->plaintext_data.version);
@@ -204,8 +205,8 @@ helper_compare_hs_desc(const hs_descriptor_t *desc1,
         case LS_IPV4:
         case LS_IPV6:
         {
-          char *addr1 = tor_addr_to_str_dup(&ls1->u.ap.addr),
-               *addr2 = tor_addr_to_str_dup(&ls2->u.ap.addr);
+          addr1 = tor_addr_to_str_dup(&ls1->u.ap.addr);
+          addr2 = tor_addr_to_str_dup(&ls2->u.ap.addr);
           tt_str_op(addr1, OP_EQ, addr2);
           tor_free(addr1);
           tor_free(addr2);
@@ -225,7 +226,8 @@ helper_compare_hs_desc(const hs_descriptor_t *desc1,
   }
 
  done:
-  ;
+  tor_free(addr1);
+  tor_free(addr2);
 }
 
 /* Test certificate encoding put in a descriptor. */

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits