X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_cache.c;h=8e915883a2a0860b757020e931f18af9cc7ff37b;hb=f8379dd45f4a43595f4027992696ee8d02908bff;hp=fa6e6603ec3e10eedcdc6ea7d56ab64a0b04db6e;hpb=4975b66d57de9e3955fe5e4afac0721e7eb0ce46;p=collectd.git diff --git a/src/utils_cache.c b/src/utils_cache.c index fa6e6603..8e915883 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -186,11 +186,13 @@ static int uc_insert (const data_set_t *ds, const value_list_t *vl, / CDTIME_T_TO_DOUBLE (vl->interval); ce->values_raw[i].absolute = vl->values[i].absolute; break; - + default: /* This shouldn't happen. */ ERROR ("uc_insert: Don't know how to handle data source type %i.", ds->ds[i].type); + sfree (key_copy); + cache_free (ce); return (-1); } /* switch (ds->ds[i].type) */ } /* for (i) */ @@ -296,7 +298,13 @@ int uc_check_timeout (void) pthread_mutex_unlock (&cache_lock); if (keys_len == 0) + { + /* realloc() may have been called for these. */ + sfree (keys); + sfree (keys_time); + sfree (keys_interval); return (0); + } /* Call the "missing" callback for each value. Do this before removing the * value from the cache, so that callbacks can still access the data stored, @@ -315,7 +323,6 @@ int uc_check_timeout (void) if (status != 0) { ERROR ("uc_check_timeout: parse_identifier_vl (\"%s\") failed.", keys[i]); - cache_free (ce); continue; } @@ -631,12 +638,13 @@ int uc_get_names (char ***ret_names, cdtime_t **ret_times, size_t *ret_number) if (status != 0) { size_t i; - + for (i = 0; i < number; i++) { sfree (names[i]); } sfree (names); + sfree (times); return (-1); } @@ -644,6 +652,8 @@ int uc_get_names (char ***ret_names, cdtime_t **ret_times, size_t *ret_number) *ret_names = names; if (ret_times != NULL) *ret_times = times; + else + sfree (times); *ret_number = number; return (0); @@ -727,7 +737,6 @@ int uc_get_history_by_name (const char *name, if (ce->history_length < num_steps) { gauge_t *tmp; - size_t i; tmp = realloc (ce->history, sizeof (*ce->history) * num_steps * ce->values_num);