Re: [PATCH] console: plug memory leaks

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

 



On 12/20/2011 10:41 AM, Alex Jia wrote:
On 12/20/2011 05:32 PM, ajia@xxxxxxxxxx wrote:
From: Alex Jia<ajia@xxxxxxxxxx>

Using 'virReallocN' to allocate memory on virConsoleEventOnStdin,
virConsoleEventOnStdout and virConsoleEventOnStream, however, the
cleanup function virConsoleShutdown hasn't released these memory.

* tools/console.c: fix memory leaks on virConsoleShutdown.

https://bugzilla.redhat.com/show_bug.cgi?id=767488

Signed-off-by: Alex Jia<ajia@xxxxxxxxxx>
---
tools/console.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/console.c b/tools/console.c
index e6118a0..86376e4 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -101,6 +101,12 @@ virConsoleShutdown(virConsolePtr con)
virStreamAbort(con->st);
virStreamFree(con->st);
}
+ if (con->streamToTerminal.data) {
+ VIR_FREE(con->streamToTerminal.data);
+ }
+ if (con->terminalToStream.data) {
+ VIR_FREE(con->terminalToStream.data);
+ }
'{}' are useless, will send a v2 to remove them.
Also the if's are not needed as freeing NULL is a perfectly fine operation.

Peter

if (con->stdinWatch != -1)
virEventRemoveHandle(con->stdinWatch);
if (con->stdoutWatch != -1)

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

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