From: Yu Zhiguo Subject: [PATCH] xenstore: Fix memory leak in command 'xenstore rm' Date: Fri, 18 Dec 2009 17:28:49 +0800 Message-ID: <4B2B4B51.4090704@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org When option '-t' is used to do tidy remove, routine xs_directory() will be called in order to check there are brother directories or not. The returned pointer should be passed to free() after this check. Signed-off-by: Yu Zhiguo diff -r 1a911fd65e52 -r 1bd6c2c5e109 tools/xenstore/xenstore_client.c --- a/tools/xenstore/xenstore_client.c Fri Dec 18 07:53:27 2009 +0000 +++ b/tools/xenstore/xenstore_client.c Fri Dec 11 23:38:23 2009 +0800 @@ -343,8 +343,10 @@ unsigned int num; char ** list = xs_directory(xsh, xth, p, &num); - if (list && num == 0) { - goto again; + if (list) { + free(list); + if (num == 0) + goto again; } } }