ia64/xen-unstable

changeset 6691:c2f3f18c0d95

Don't leak memory when realloc fails.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 07 19:13:38 2005 +0000 (2005-09-07)
parents 7d0fb56b4a91
children 0c9c044fd00c
files tools/console/daemon/io.c
line diff
     1.1 --- a/tools/console/daemon/io.c	Wed Sep 07 19:01:31 2005 +0000
     1.2 +++ b/tools/console/daemon/io.c	Wed Sep 07 19:13:38 2005 +0000
     1.3 @@ -279,6 +279,7 @@ static bool watch_domain(struct domain *
     1.4  static struct domain *create_domain(int domid)
     1.5  {
     1.6  	struct domain *dom;
     1.7 +	char *s;
     1.8  
     1.9  	dom = (struct domain *)malloc(sizeof(struct domain));
    1.10  	if (dom == NULL) {
    1.11 @@ -306,10 +307,11 @@ static struct domain *create_domain(int 
    1.12  	dom->conspath = xs_get_domain_path(xs, dom->domid);
    1.13  	if (dom->conspath == NULL)
    1.14  		goto out;
    1.15 -	dom->conspath = realloc(dom->conspath, strlen(dom->conspath) +
    1.16 -				strlen("/console") + 1);
    1.17 -	if (dom->conspath == NULL)
    1.18 +	s = realloc(dom->conspath, strlen(dom->conspath) +
    1.19 +		    strlen("/console") + 1);
    1.20 +	if (s == NULL)
    1.21  		goto out;
    1.22 +	dom->conspath = s;
    1.23  	strcat(dom->conspath, "/console");
    1.24  
    1.25  	if (!watch_domain(dom, true))