From: Florian Forster Date: Mon, 8 Oct 2012 14:20:34 +0000 (+0200) Subject: src/utils_avltree.c: Fix an off-by-one error in c_avl_insert(). X-Git-Tag: collectd-5.1.1~4^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=60c6faf4fe7779e3d2f1c0c807103bbd2ee0c697;p=collectd.git src/utils_avltree.c: Fix an off-by-one error in c_avl_insert(). When inserting the first node in the tree, the size is not incremented. This causes c_avl_size() to return one element too little. Thanks to Yves Mettier for debugging this! --- diff --git a/src/utils_avltree.c b/src/utils_avltree.c index ba7cd95f..f71b1fd6 100644 --- a/src/utils_avltree.c +++ b/src/utils_avltree.c @@ -512,6 +512,7 @@ int c_avl_insert (c_avl_tree_t *t, void *key, void *value) { new->parent = NULL; t->root = new; + t->size = 1; return (0); }