X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=16e07247b3cf56d07937d677c1eddf861c5c2655;hb=a7b0cdea4f6a0f8d29ade21ae058182f720dd432;hp=8fc6f7d730222a5b8c34585ef701737ad056b4d1;hpb=24c2f247f6dc5c17b26d715346a380efababb08f;p=collectd.git diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 8fc6f7d7..16e07247 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -623,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; @@ -713,6 +716,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)); @@ -732,6 +736,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); @@ -744,6 +749,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); @@ -756,7 +762,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); @@ -781,11 +790,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