X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fconfigfile.c;h=ec39b76034fa21c8d8a9f4c066f0419d6f0bcb79;hb=587f01f89af11c4acebbec44293528b77c779218;hp=0e54f267f9fdd08c15d4d4d11a427f409d708723;hpb=7fc4c1f412c4002b787b5ce24b08e3091ced08a5;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index 0e54f267..ec39b760 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -477,6 +477,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)); @@ -591,7 +597,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;