Re: [PATCH/RFC] remote driver uses already freed dom

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

 



...and here's the patch attached again. It seems mailman stripped the
attachment and the original mail into two parts because of the git
headers.
 -- Guido
---
 src/virterror.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/virterror.c b/src/virterror.c
index 1463129..49f3b89 100644
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -115,6 +115,11 @@ virResetError(virErrorPtr err)
     free(err->str1);
     free(err->str2);
     free(err->str3);
+    if(err->dom) {
+        if(err->dom->name)
+            free(err->dom->name);
+        free(err->dom);
+    }
     memset(err, 0, sizeof(virError));
 }
 
@@ -383,6 +388,15 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net,
     virResetError(to);
     to->conn = conn;
     to->dom = dom;
+    if (dom) {
+        if (!(to->dom = malloc(sizeof(virDomain)))) {
+            fprintf(stderr, "cannot allocate memory in %s", __FUNCTION__);
+        } else {
+            to->dom->name = strdup(dom->name);
+            memcpy (to->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
+            to->dom->id = dom->id;
+        }
+    }
     to->net = net;
     to->domain = domain;
     to->code = code;
-- 
1.5.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]