From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [PATCH v3 07/10] xl: correct handling of extra_config in main_cpupoolcreate Date: Tue, 14 Jul 2015 17:41:10 +0100 Message-ID: <1436892073-14186-8-git-send-email-wei.liu2@citrix.com> References: <1436892073-14186-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZF3Gg-0002RU-F7 for xen-devel@lists.xenproject.org; Tue, 14 Jul 2015 16:41:18 +0000 In-Reply-To: <1436892073-14186-1-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Wei Liu , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Don't dereference extra_config if it's NULL. Don't leak extra_config in the end. Also fixed a typo in error string while I was there. Signed-off-by: Wei Liu --- tools/libxl/xl_cmdimpl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 971209c..607db4e 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7228,9 +7228,9 @@ int main_cpupoolcreate(int argc, char **argv) else config_src="command line"; - if (strlen(extra_config)) { + if (extra_config && strlen(extra_config)) { if (config_len > INT_MAX - (strlen(extra_config) + 2)) { - fprintf(stderr, "Failed to attach extra configration\n"); + fprintf(stderr, "Failed to attach extra configuration\n"); goto out; } config_data = xrealloc(config_data, @@ -7365,6 +7365,7 @@ out_cfg: out: free(name); free(config_data); + free(extra_config); return rc; } -- 1.9.1