Code

configfile: cf_read_dir: Don't abort reading a directory when reading one file fails.
authorFlorian Forster <octo@noris.net>
Wed, 3 Mar 2010 14:44:11 +0000 (15:44 +0100)
committerFlorian Forster <octo@noris.net>
Wed, 10 Mar 2010 17:40:06 +0000 (18:40 +0100)
src/configfile.c

index d401a2e1e0e2998a1a965fa9b31acb2532106682..34049f2ee6e9df6f7ab501347b4495584a0af4eb 100644 (file)
@@ -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);