WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Don't leak memory when realloc fails.

# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID c2f3f18c0d959bfdcb55828a8e387e784948ab34
# Parent  7d0fb56b4a916cccc497d200e6a8329537ce740d
Don't leak memory when realloc fails.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 7d0fb56b4a91 -r c2f3f18c0d95 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Wed Sep  7 19:01:31 2005
+++ b/tools/console/daemon/io.c Wed Sep  7 19:13:38 2005
@@ -279,6 +279,7 @@
 static struct domain *create_domain(int domid)
 {
        struct domain *dom;
+       char *s;
 
        dom = (struct domain *)malloc(sizeof(struct domain));
        if (dom == NULL) {
@@ -306,10 +307,11 @@
        dom->conspath = xs_get_domain_path(xs, dom->domid);
        if (dom->conspath == NULL)
                goto out;
-       dom->conspath = realloc(dom->conspath, strlen(dom->conspath) +
-                               strlen("/console") + 1);
-       if (dom->conspath == NULL)
+       s = realloc(dom->conspath, strlen(dom->conspath) +
+                   strlen("/console") + 1);
+       if (s == NULL)
                goto out;
+       dom->conspath = s;
        strcat(dom->conspath, "/console");
 
        if (!watch_domain(dom, true))

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Don't leak memory when realloc fails., Xen patchbot -unstable <=