- fix memory leak
authorMichael Schroeder <mls@suse.de>
Wed, 4 Aug 2010 12:36:53 +0000 (14:36 +0200)
committerMichael Schroeder <mls@suse.de>
Wed, 4 Aug 2010 12:36:53 +0000 (14:36 +0200)
zypp/media/MediaMultiCurl.cc

index a9b0d3d49e7c3e87dcff9c148f298243ae19a412..e105a2f5e115730b9adc528c581456a51cbacec6 100644 (file)
@@ -1149,6 +1149,16 @@ MediaMultiCurl::~MediaMultiCurl()
       curl_multi_cleanup(_multi);
       _multi = 0;
     }
+  std::map<std::string, CURL *>::iterator it;
+  for (it = _easypool.begin(); it != _easypool.end(); it++)
+    {
+      CURL *easy = it->second;
+      if (easy)
+       {
+         curl_easy_cleanup(easy);
+         it->second = NULL;
+       }
+    }
 }
 
 void MediaMultiCurl::setupEasy()
@@ -1406,7 +1416,10 @@ CURL *MediaMultiCurl::fromEasyPool(const string &host) const
 
 void MediaMultiCurl::toEasyPool(const std::string &host, CURL *easy) const
 {
+  CURL *oldeasy = _easypool[host];
   _easypool[host] = easy;
+  if (oldeasy)
+    curl_easy_cleanup(oldeasy);
 }
 
   } // namespace media