xl: do not leak cpupool names.
authorIan Campbell <ian.campbell@citrix.com>
Fri, 14 Sep 2012 09:02:50 +0000 (10:02 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 14 Sep 2012 09:02:50 +0000 (10:02 +0100)
commit10a194b1c57de7ddc9d4fce07e01f2cd7d0ca26a
treef534d44504976bef99a331cbfe712ffa36198c4b
parent3c73d5f9473dfa897201dc03dc719bd1ccf8b77b
xl: do not leak cpupool names.

Valgrind reports:
==3076== 7 bytes in 1 blocks are definitely lost in loss record 1 of 1
==3076==    at 0x402458C: malloc (vg_replace_malloc.c:270)
==3076==    by 0x406F86D: libxl_cpupoolid_to_name (libxl_utils.c:102)
==3076==    by 0x8058742: parse_config_data (xl_cmdimpl.c:639)
==3076==    by 0x805BD56: create_domain (xl_cmdimpl.c:1838)
==3076==    by 0x805DAED: main_create (xl_cmdimpl.c:3903)
==3076==    by 0x804D39D: main (xl.c:285)

And indeed there are several places where xl uses
libxl_cpupoolid_to_name as a boolean to test if the pool name is
valid and leaks the name if it is. Introduce an is_valid helper and
use that instead.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Juergen Gross<juergen.gross@ts.fujitsu.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_utils.c
tools/libxl/libxl_utils.h
tools/libxl/xl_cmdimpl.c
tools/libxl/xl_sxp.c