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] [xen-unstable] [XENSTAT] Fix two realloc() usage errors

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XENSTAT] Fix two realloc() usage errors in xenstat.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 14 Jun 2006 15:25:35 +0000
Delivery-date: Wed, 14 Jun 2006 08:28:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxxxx
# Node ID 578e306b0bd41eb0d2e5b4c904123eb730722212
# Parent  1e49997c8146b7c12face5ac4ab19c67ae726863
[XENSTAT] Fix two realloc() usage errors in xenstat.
Based on original patch from Jimi Xenidis at IBM.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/xenstat/libxenstat/src/xenstat.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff -r 1e49997c8146 -r 578e306b0bd4 tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c    Wed Jun 14 13:11:44 2006 +0100
+++ b/tools/xenstat/libxenstat/src/xenstat.c    Wed Jun 14 13:31:38 2006 +0100
@@ -223,18 +223,20 @@ xenstat_node *xenstat_get_node(xenstat_h
 
        num_domains = 0;
        do {
-               xenstat_domain *domain;
+               xenstat_domain *domain, *tmp;
 
                new_domains = xc_domain_getinfolist(handle->xc_handle,
                        num_domains, DOMAIN_CHUNK_SIZE, domaininfo);
 
-               node->domains = realloc(node->domains,
-                                       (num_domains + new_domains)
-                                       * sizeof(xenstat_domain));
-               if (node->domains == NULL) {
+               tmp = realloc(node->domains,
+                             (num_domains + new_domains)
+                             * sizeof(xenstat_domain));
+               if (tmp == NULL) {
+                       free(node->domains);
                        free(node);
                        return NULL;
                }
+               node->domains = tmp;
 
                domain = node->domains + num_domains;
 
@@ -582,11 +584,14 @@ static int xenstat_collect_networks(xens
                        domain->num_networks = 1;
                        domain->networks = malloc(sizeof(xenstat_network));
                } else {
+                       struct xenstat_network *tmp;
                        domain->num_networks++;
-                       domain->networks =
-                           realloc(domain->networks,
-                                   domain->num_networks *
-                                   sizeof(xenstat_network));
+                       tmp = realloc(domain->networks,
+                                     domain->num_networks *
+                                     sizeof(xenstat_network));
+                       if (tmp == NULL)
+                               free(domain->networks);
+                       domain->networks = tmp;
                }
                if (domain->networks == NULL)
                        return 0;

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XENSTAT] Fix two realloc() usage errors in xenstat., Xen patchbot-unstable <=