From 813fadc54fbf0c9b948163851e9791a1ace716ae Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 19 Jun 2015 07:05:22 +0200 Subject: [PATCH] src/utils_cache.c: Fix two memory leaks. * Free "times" pointer if it is not returned to the user. * Free (re)alloc'ed pointers when strdup() fails. --- src/utils_cache.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils_cache.c b/src/utils_cache.c index e77f9942..dc0ff0df 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -296,7 +296,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, @@ -643,6 +649,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); -- 2.30.2