[lxc-devel] [PATCH 2/2] coverity: malloc the right size for btrs_node tree

Serge Hallyn serge.hallyn at ubuntu.com
Mon Aug 11 14:10:59 UTC 2014


We were allocating sizeof(tree) instead of sizeof(*tree).

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/bdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
index 2d5bfea..e4b32a1 100644
--- a/src/lxc/bdev.c
+++ b/src/lxc/bdev.c
@@ -1587,7 +1587,7 @@ static struct my_btrfs_tree *create_my_btrfs_tree(u64 id, const char *path, int
 {
 	struct my_btrfs_tree *tree;
 
-	tree = malloc(sizeof(tree));
+	tree = malloc(sizeof(struct my_btrfs_tree));
 	if (!tree)
 		return NULL;
 	tree->nodes = malloc(sizeof(struct mytree_node));
-- 
2.1.0.rc1



More information about the lxc-devel mailing list