X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fconfigfile.c;h=983d99569796fde8b684242663106357e3506d3d;hb=c6da31fb30c2fb1d131f92efcde0b3ec9a010b2c;hp=787ad0ea388485e247cdebb4027dec89f0218211;hpb=26be7bb8e6eaab8d1b24a721a634d273337185af;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index 787ad0ea..983d9956 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -414,6 +414,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)); @@ -514,7 +520,8 @@ static int cf_include_all (oconfig_item_t *root, int depth) continue; /* 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; @@ -701,11 +708,10 @@ static oconfig_item_t *cf_read_generic (const char *path, int depth) if (status != 0) { char errbuf[1024]; - ERROR ("configfile: stat (%s) failed: %s", + WARNING ("configfile: stat (%s) failed: %s", path_ptr, sstrerror (errno, errbuf, sizeof (errbuf))); - oconfig_free (root); - return (NULL); + continue; } if (S_ISREG (statbuf.st_mode)) @@ -714,7 +720,7 @@ static oconfig_item_t *cf_read_generic (const char *path, int depth) temp = cf_read_dir (path_ptr, depth); else { - ERROR ("configfile: %s is neither a file nor a " + WARNING ("configfile: %s is neither a file nor a " "directory.", path); continue; } @@ -731,6 +737,12 @@ static oconfig_item_t *cf_read_generic (const char *path, int depth) wordfree (&we); + if (root->children == NULL) + { + oconfig_free (root); + return (NULL); + } + return (root); } /* oconfig_item_t *cf_read_generic */ /* #endif HAVE_WORDEXP_H */