All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] tools/xenstore: Fix memory leaks in the client
Date: Mon, 2 Jun 2014 10:42:13 +0100	[thread overview]
Message-ID: <538C46F5.3040205@citrix.com> (raw)
In-Reply-To: <1400841121-26874-1-git-send-email-andrew.cooper3@citrix.com>

Ping

On 23/05/14 11:32, Andrew Cooper wrote:
> Free the expanding buffer and output buffer after use.  Close the xenstore
> handle after use.
>
> The command line client is now valgrind-clean.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> CC: Ian Campbell <Ian.Campbell@citrix.com>
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> ---
>  tools/xenstore/xenstore_client.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c
> index 0ec103f..56b9309 100644
> --- a/tools/xenstore/xenstore_client.c
> +++ b/tools/xenstore/xenstore_client.c
> @@ -40,6 +40,7 @@ enum mode {
>  
>  static char *output_buf = NULL;
>  static int output_pos = 0;
> +static struct expanding_buffer ebuf;
>  
>  static int output_size = 0;
>  
> @@ -126,7 +127,6 @@ static int show_whole_path = 0;
>  
>  static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms)
>  {
> -    static struct expanding_buffer ebuf;
>      char **e;
>      char newpath[STRING_MAX], *val;
>      int newpath_len;
> @@ -308,7 +308,6 @@ perform(enum mode mode, int optind, int argc, char **argv, struct xs_handle *xsh
>              /* CANNOT BE REACHED */
>              errx(1, "invalid mode %d", mode);
>          case MODE_read: {
> -            static struct expanding_buffer ebuf;
>              unsigned len;
>              char *val = xs_read(xsh, xth, argv[optind], &len);
>              if (val == NULL) {
> @@ -323,7 +322,6 @@ perform(enum mode mode, int optind, int argc, char **argv, struct xs_handle *xsh
>              break;
>          }
>          case MODE_write: {
> -            static struct expanding_buffer ebuf;
>              char *val_spec = argv[optind + 1];
>              unsigned len;
>              expanding_buffer_ensure(&ebuf, strlen(val_spec)+1);
> @@ -655,5 +653,11 @@ again:
>      if (output_pos)
>  	printf("%s", output_buf);
>  
> +    free(output_buf);
> +    free(ebuf.buf);
> +
> +    if (xsh)
> +        xs_close(xsh);
> +
>      return ret;
>  }

  reply	other threads:[~2014-06-02  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 10:32 [PATCH] tools/xenstore: Fix memory leaks in the client Andrew Cooper
2014-06-02  9:42 ` Andrew Cooper [this message]
2014-06-02 14:41 ` Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=538C46F5.3040205@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.