[libvirt] [PATCH] uml_driver.c: avoid leak upon failure

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

 



Without this, it looked like every caller (there's only one;
the other use is if-0'd out) could leak the result buffer.

>From 8b8874b956c822562151cb90b1a8950d17b565ac Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Mon, 15 Feb 2010 19:22:38 +0100
Subject: [PATCH] uml_driver.c: avoid leak upon failure

* src/uml/uml_driver.c (umlMonitorCommand): This function would
sometimes return -1, yet fail to free the "reply" it had allocated.
Hence, no caller would know to free the corresponding argument.
When returning -1, be sure to free all allocated resources.
---
 src/uml/uml_driver.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 5049c92..10268db 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1,7 +1,7 @@
 /*
  * uml_driver.c: core driver methods for managing UML guests
  *
- * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
  * Copyright (C) 2006-2008 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -757,7 +757,10 @@ static int umlMonitorCommand(virConnectPtr conn,

     VIR_DEBUG("Command reply is '%s'", NULLSTR(retdata));

-    *reply = retdata;
+    if (ret < 0)
+        VIR_FREE(retdata);
+    else
+        *reply = retdata;

     return ret;

--
1.7.0.181.g41533

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