From: Sebastian Harl Date: Wed, 8 Jul 2009 11:19:57 +0000 (+0200) Subject: src/utils_cache.c: Make really sure to free the right cache entry. X-Git-Tag: collectd-4.6.5~29^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c2593281c3ed2919f67514381be2b5137308f3af;p=collectd.git src/utils_cache.c: Make really sure to free the right cache entry. Make sure we do not try to free a (possibly some random) cache entry after removing it from the AVL tree. Potentially, this might have caused invalid free()s in some rare situations. --- diff --git a/src/utils_cache.c b/src/utils_cache.c index 60d32832..33dc6b15 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -296,6 +296,7 @@ int uc_check_timeout (void) { DEBUG ("uc_check_timeout: %s is missing but ``uninteresting''", keys[i]); + ce = NULL; status = c_avl_remove (cache_tree, keys[i], (void *) &key, (void *) &ce); if (status != 0) @@ -304,7 +305,8 @@ int uc_check_timeout (void) } sfree (keys[i]); sfree (key); - cache_free (ce); + if (ce != NULL) + cache_free (ce); continue; }