X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fconfigfile.c;h=7e06baa2c83b7eaeb78005fd545105119848d64e;hp=154c041cee2d8b6d01ff4021c723810993c91dac;hb=96e0f2341bace029acefe0a88bab96ae326c0ff5;hpb=c6a433718fa3bc3b6192153fee23558ddf011838 diff --git a/src/configfile.c b/src/configfile.c index 154c041c..7e06baa2 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -476,6 +476,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)); @@ -590,7 +596,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;