[libvirt] [snmp PATCH 01/20] libvirtGuestTable.c: Free duplicated domain name

Michal Privoznik posted 20 patches 6 years, 1 month ago
[libvirt] [snmp PATCH 01/20] libvirtGuestTable.c: Free duplicated domain name
Posted by Michal Privoznik 6 years, 1 month ago
The domain name is duplicated in insertGuest() but it's never
freed leading to the following memleak:

 46 bytes in 6 blocks are definitely lost in loss record 795 of 944
    at 0x4C2CF0F: malloc (vg_replace_malloc.c:299)
    by 0x6E6FE79: strdup (in /lib64/libc-2.26.so)
    by 0x10E665: insertGuest (libvirtSnmp.c:160)
    by 0x10EA7D: libvirtSnmpLoadGuests (libvirtSnmp.c:285)
    by 0x10DB01: libvirtGuestTable_container_load (libvirtGuestTable_data_access.c:230)
    by 0x1133E3: _cache_load (libvirtGuestTable_interface.c:1557)
    by 0x5F2955B: _cache_load (in /usr/lib64/libnetsnmpagent.so.30.0.3)
    by 0x5F2A7FF: netsnmp_cache_helper_handler (in /usr/lib64/libnetsnmpagent.so.30.0.3)
    by 0x5F3CE2C: netsnmp_call_next_handler (in /usr/lib64/libnetsnmpagent.so.30.0.3)
    by 0x5F316B6: table_helper_handler (in /usr/lib64/libnetsnmpagent.so.30.0.3)
    by 0x5F3C8E6: netsnmp_call_handlers (in /usr/lib64/libnetsnmpagent.so.30.0.3)
    by 0x5F4A65E: handle_var_requests (in /usr/lib64/libnetsnmpagent.so.30.0.3)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/libvirtGuestTable.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/libvirtGuestTable.c b/src/libvirtGuestTable.c
index cb4c59f..80645f2 100644
--- a/src/libvirtGuestTable.c
+++ b/src/libvirtGuestTable.c
@@ -157,9 +157,7 @@ void libvirtGuestTable_rowreq_ctx_cleanup(libvirtGuestTable_rowreq_ctx *rowreq_c
 
     netsnmp_assert(NULL != rowreq_ctx);
 
-    /*
-     * TODO:211:o: |-> Perform extra libvirtGuestTable rowreq cleanup.
-     */
+    free(rowreq_ctx->data.libvirtGuestName);
 } /* libvirtGuestTable_rowreq_ctx_cleanup */
 
 /**
-- 
2.18.1

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