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