From: Florian Forster Date: Wed, 3 Mar 2010 14:44:11 +0000 (+0100) Subject: configfile: cf_read_dir: Don't abort reading a directory when reading one file fails. X-Git-Tag: collectd-4.8.4~11 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c758b708081f9035cdb1673a52fa5c8cc2956fbb;p=collectd.git configfile: cf_read_dir: Don't abort reading a directory when reading one file fails. --- diff --git a/src/configfile.c b/src/configfile.c index d401a2e1..34049f2e 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -559,14 +559,14 @@ static oconfig_item_t *cf_read_dir (const char *dir, int depth) ERROR ("configfile: malloc failed."); return (NULL); } - memset (root, '\0', sizeof (oconfig_item_t)); + memset (root, 0, sizeof (oconfig_item_t)); while ((de = readdir (dh)) != NULL) { char name[1024]; char **tmp; - if ((de->d_name[0] == '.') || (de->d_name[0] == '\0')) + if ((de->d_name[0] == '.') || (de->d_name[0] == 0)) continue; status = ssnprintf (name, sizeof (name), "%s/%s", @@ -608,13 +608,11 @@ static oconfig_item_t *cf_read_dir (const char *dir, int depth) char *name = filenames[i]; temp = cf_read_generic (name, depth); - if (temp == NULL) { - int j; - for (j = i; j < filenames_num; ++j) - free (filenames[j]); - free (filenames); - oconfig_free (root); - return (NULL); + if (temp == NULL) + { + /* An error should already have been reported. */ + sfree (name); + continue; } cf_ci_append_children (root, temp);