From 409f2a041f752ef635354e1dc7b2759fcd7088d6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 18 Nov 2012 16:17:37 +0100 Subject: fixed memory leak: CURLOPT_RESOLVE with multi interface DNS cache entries populated with CURLOPT_RESOLVE were not properly freed again when done using the multi interface. Test case 1502 added to verify. Bug: http://curl.haxx.se/bug/view.cgi?id=3575448 Reported by: Alex Gruz --- lib/hostip.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/hostip.c') diff --git a/lib/hostip.c b/lib/hostip.c index 503ba483f..ef14ce863 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -740,14 +740,18 @@ static int hostcache_inuse(void *data, void *hc) return 1; /* free all entries */ } -void Curl_hostcache_destroy(struct SessionHandle *data) +void Curl_hostcache_clean(struct SessionHandle *data) { /* Entries added to the hostcache with the CURLOPT_RESOLVE function are * still present in the cache with the inuse counter set to 1. Detect them * and cleanup! */ Curl_hash_clean_with_criterium(data->dns.hostcache, data, hostcache_inuse); +} +void Curl_hostcache_destroy(struct SessionHandle *data) +{ + Curl_hostcache_clean(data); Curl_hash_destroy(data->dns.hostcache); data->dns.hostcachetype = HCACHE_NONE; data->dns.hostcache = NULL; -- cgit v1.2.3