xfs
[Top] [All Lists]

[PATCH 8/9] xfsdump: children[] is an array of child pointers, not of ch

To: xfs@xxxxxxxxxxx
Subject: [PATCH 8/9] xfsdump: children[] is an array of child pointers, not of child structures
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Wed, 12 Nov 2014 12:57:17 -0600
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1415818638-32700-1-git-send-email-sandeen@xxxxxxxxxx>
References: <1415818638-32700-1-git-send-email-sandeen@xxxxxxxxxx>
node_t      **children;     /* child nodes */

so allocating space to hold nbr_children structures is wrong;
we need to hold nbr_children _pointers_ to child structures.

It's over-allocating, so it's relatively harmless.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---
 invutil/list.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/invutil/list.c b/invutil/list.c
index 0157102..599e6af 100644
--- a/invutil/list.c
+++ b/invutil/list.c
@@ -34,7 +34,7 @@ parent_add_child(node_t *parent, node_t *child)
     d = parent->data;
 
     d->nbr_children++;
-    d->children = realloc(d->children, d->nbr_children * sizeof(*child));
+    d->children = realloc(d->children, d->nbr_children * sizeof(node_t *));
     d->children[d->nbr_children - 1] = child;
 
     return parent;
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>