[Libvirt-cim] [PATCH 1/3] list_util: Fix possible memory leak
Daniel Veillard
veillard at redhat.com
Wed Jun 20 06:32:44 UTC 2012
On Tue, Jun 19, 2012 at 12:35:38PM -0300, Eduardo Lima (Etrunko) wrote:
> From: "Eduardo Lima (Etrunko)" <eblima at br.ibm.com>
>
> The list pointer was leaking in the case where the list was empty.
>
> Signed-off-by: Eduardo Lima (Etrunko) <eblima at br.ibm.com>
> ---
> libxkutil/list_util.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libxkutil/list_util.c b/libxkutil/list_util.c
> index 84b2ba0..cab0287 100644
> --- a/libxkutil/list_util.c
> +++ b/libxkutil/list_util.c
> @@ -54,9 +54,12 @@ void list_free(list_t *list)
> {
> list_node_t *n, *next;
>
> - if (list == NULL || list->head == NULL)
> + if (list == NULL)
> return;
>
> + if (list->head == NULL)
> + goto end;
> +
> n = list->head;
>
> do {
> @@ -68,6 +71,7 @@ void list_free(list_t *list)
> n = next;
> } while (n != list->head);
>
> + end:
> free(list);
> }
Patch looks reasonable based on the description, ACK
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the Libvirt-cim
mailing list