[PATCH 7/3] rpc: avoid crash on error

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

 



Detected by Coverity.  Freeing the wrong variable results in both
a memory leak and the likelihood of the caller dereferencing through
a freed pointer.

* src/rpc/virnettlscontext.c (virNetTLSSessionNew): Free correct
variable.
---
 src/rpc/virnettlscontext.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index be08207..eeffe54 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -1164,17 +1164,17 @@ virNetTLSSessionPtr virNetTLSSessionNew(virNetTLSContextPtr ctxt,
     if (VIR_ALLOC(sess) < 0) {
         virReportOOMError();
         return NULL;
     }

     if (virMutexInit(&sess->lock) < 0) {
         virNetError(VIR_ERR_INTERNAL_ERROR, "%s",
                     _("Failed to initialized mutex"));
-        VIR_FREE(ctxt);
+        VIR_FREE(sess);
         return NULL;
     }

     sess->refs = 1;
     if (hostname &&
         !(sess->hostname = strdup(hostname))) {
         virReportOOMError();
         goto error;
-- 
1.7.4.4

--
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]