[PATCH 1/2] tests: avoid memory leak on testTLSSessionInit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* tests/virnettlscontexttest: fix memory leak on virnettlscontext test case.

* Detected in valgrind run:

==25667==
==25667== 86,651 (34,680 direct, 51,971 indirect) bytes in 10 blocks are
definitely lost in loss record 350 of 351
==25667==    at 0x4005447: calloc (vg_replace_malloc.c:467)
==25667==    by 0x4F1F515D: gnutls_init (gnutls_state.c:270)
==25667==    by 0x8053432: virNetTLSSessionNew (virnettlscontext.c:1181)
==25667==    by 0x804DD24: testTLSSessionInit (virnettlscontexttest.c:624)
==25667==    by 0x804F14D: virtTestRun (testutils.c:140)
==25667==
==25667== 100,578 (38,148 direct, 62,430 indirect) bytes in 11 blocks are
definitely lost in loss record 351 of 351
==25667==    at 0x4005447: calloc (vg_replace_malloc.c:467)
==25667==    by 0x4F1F515D: gnutls_init (gnutls_state.c:270)
==25667==    by 0x8053432: virNetTLSSessionNew (virnettlscontext.c:1181)
==25667==    by 0x804DD3C: testTLSSessionInit (virnettlscontexttest.c:625)
==25667==    by 0x804F14D: virtTestRun (testutils.c:140)

* How to reproduce?
% cd libvirt && ./configure && make && make -C tests valgrind
or
% valgrind -v --leak-check=full ./tests/virnettlscontexttest 

Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 tests/virnettlscontexttest.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index ee7b6b4..ece611a 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -712,6 +712,8 @@ static int testTLSSessionInit(const void *opaque)
 cleanup:
     virNetTLSContextFree(serverCtxt);
     virNetTLSContextFree(clientCtxt);
+    virNetTLSSessionFree(serverSess);
+    virNetTLSSessionFree(clientSess);
     gnutls_x509_crt_deinit(data->careq.crt);
     if (data->othercareq.filename)
         gnutls_x509_crt_deinit(data->othercareq.crt);
-- 
1.7.5.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]