X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=89b0be0b1cc780dc7e185bb232f7123b33344e31;hb=749b03b3fc459895b7415c7c13753066bf0af55b;hp=f367ee9c3973d19ddc0acba2e1adc46a2cdeadf6;hpb=872126c9a7e0a8f8ae2b28217c12c27c35af5237;p=collectd.git diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index f367ee9c..89b0be0b 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -628,8 +628,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; @@ -718,6 +721,7 @@ static oconfig_item_t *cf_read_dir (const char *dir, if (root == NULL) { ERROR ("configfile: malloc failed."); + closedir (dh); return (NULL); } memset (root, 0, sizeof (oconfig_item_t)); @@ -737,6 +741,7 @@ static oconfig_item_t *cf_read_dir (const char *dir, ERROR ("configfile: Not including `%s/%s' because its" " name is too long.", dir, de->d_name); + closedir (dh); for (i = 0; i < filenames_num; ++i) free (filenames[i]); free (filenames); @@ -749,6 +754,7 @@ static oconfig_item_t *cf_read_dir (const char *dir, filenames_num * sizeof (*filenames)); if (tmp == NULL) { ERROR ("configfile: realloc failed."); + closedir (dh); for (i = 0; i < filenames_num - 1; ++i) free (filenames[i]); free (filenames); @@ -761,7 +767,10 @@ static oconfig_item_t *cf_read_dir (const char *dir, } if (filenames == NULL) + { + closedir (dh); return (root); + } qsort ((void *) filenames, filenames_num, sizeof (*filenames), cf_compare_string); @@ -786,11 +795,12 @@ static oconfig_item_t *cf_read_dir (const char *dir, free (name); } + closedir (dh); free(filenames); return (root); } /* oconfig_item_t *cf_read_dir */ -/* +/* * cf_read_generic * * Path is stat'ed and either cf_read_file or cf_read_dir is called