From c758b708081f9035cdb1673a52fa5c8cc2956fbb Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 3 Mar 2010 15:44:11 +0100 Subject: [PATCH] configfile: cf_read_dir: Don't abort reading a directory when reading one file fails. --- src/configfile.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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); -- 2.11.0