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

Re: [libvirt] [PATCH 2/2] qemuhotplugtest: Resolve some memleaks

On 07/18/13 12:44, Michal Privoznik wrote:
If testQemuHotplugAttach succeeds, the vm->def steals the dev pointer.
However, not the envelope, which needs to be freed. In addition,
driver.config is allocated, but never freed.
  tests/qemuhotplugtest.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index d4971c2..5e8c5f0 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -89,6 +89,10 @@ testQemuHotplugAttach(virDomainObjPtr vm,
      switch (dev->type) {
          ret = qemuDomainAttachChrDevice(&driver, vm, dev->data.chr);
+        if (!ret) {

For integer comparisons I prefer "if (ret == 0)", this looks like returning a pointer at first glance.

+            /* vm->def stolen dev->data.chr so we ought to avoid freeing it */
+            dev->data.chr = NULL;
+        }
          if (virTestGetVerbose())

ACK anyways.


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