[libvirt] [PATCHv2] console: plug memory leaks
Eric Blake
eblake at redhat.com
Tue Dec 20 20:37:45 UTC 2011
On 12/20/2011 02:40 AM, ajia at redhat.com wrote:
> From: Alex Jia <ajia at redhat.com>
>
> 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 at redhat.com>
> ---
> tools/console.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/tools/console.c b/tools/console.c
> index e6118a0..63e51ce 100644
> --- a/tools/console.c
> +++ b/tools/console.c
> @@ -101,6 +101,10 @@ 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);
This fails 'make syntax-check'.
ACK to the leak fix, though, so pushing with this squashed in:
diff --git i/tools/console.c w/tools/console.c
index 63e51ce..4a32522 100644
--- i/tools/console.c
+++ w/tools/console.c
@@ -1,7 +1,7 @@
/*
* console.c: A dumb serial console client
*
- * Copyright (C) 2007, 2008, 2010 Red Hat, Inc.
+ * Copyright (C) 2007-2008, 2010-2011 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -101,10 +101,8 @@ 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);
+ VIR_FREE(con->streamToTerminal.data);
+ VIR_FREE(con->terminalToStream.data);
if (con->stdinWatch != -1)
virEventRemoveHandle(con->stdinWatch);
if (con->stdoutWatch != -1)
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111220/35c2506c/attachment-0001.sig>
More information about the libvir-list
mailing list