X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fconfigfile.c;h=d2a307d9451d97babd69c1a14e4fd0548dc9c4ae;hb=103f05e098865196fc5f28df51e99b64fd6b5202;hp=855681b5e10092755ff7190b0445ff43116212da;hpb=2761756b5ad2c9a973b30540633218202860a4d7;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index 855681b5..d2a307d9 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -481,6 +481,12 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src, /* Resize the memory containing the children to be big enough to hold * all children. */ + if (dst->children_num + src->children_num - 1 == 0) + { + dst->children_num = 0; + return (0); + } + temp = (oconfig_item_t *) realloc (dst->children, sizeof (oconfig_item_t) * (dst->children_num + src->children_num - 1)); @@ -595,7 +601,8 @@ static int cf_include_all (oconfig_item_t *root, int depth) return (-1); /* Now replace the i'th child in `root' with `new'. */ - cf_ci_replace_child (root, new, i); + if (cf_ci_replace_child (root, new, i) < 0) + return (-1); /* ... and go back to the new i'th child. */ --i;