X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=ae3e79899d2eddf1304bcc00ba178289b3602d02;hb=d8a02e6c6f5875dfcab7b011d1f340e3a13c9e39;hp=765a23c4d19acaf6b695f23fc909d972f56ec417;hpb=d6491cfcf52a74498e1becd7ef94fc8e0a5938b9;p=collectd.git diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 765a23c4..ae3e7989 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -156,9 +156,12 @@ static int cf_dispatch (const char *type, const char *orig_key, int ret; int i; + if (orig_key == NULL) + return (EINVAL); + DEBUG ("type = %s, key = %s, value = %s", ESCAPE_NULL(type), - ESCAPE_NULL(orig_key), + orig_key, ESCAPE_NULL(orig_value)); if ((cf_cb = cf_search (type)) == NULL) @@ -199,8 +202,6 @@ static int cf_dispatch (const char *type, const char *orig_key, free (key); free (value); - DEBUG ("cf_dispatch: return (%i)", ret); - return (ret); } /* int cf_dispatch */ @@ -622,8 +623,11 @@ static int cf_include_all (oconfig_item_t *root, int depth) return (-1); /* Now replace the i'th child in `root' with `new'. */ - if (cf_ci_replace_child (root, new, i) < 0) + if (cf_ci_replace_child (root, new, i) < 0) { + sfree (new->values); + sfree (new); return (-1); + } /* ... and go back to the new i'th child. */ --i; @@ -754,6 +758,9 @@ static oconfig_item_t *cf_read_dir (const char *dir, filenames[filenames_num - 1] = sstrdup (name); } + if (filenames == NULL) + return (root); + qsort ((void *) filenames, filenames_num, sizeof (*filenames), cf_compare_string);