[devel] [PATCH for apt 28/38] Fix resource leaks in pkgCacheFile class
Aleksei Nikiforov
darktemplar на altlinux.org
Вт Дек 10 18:23:33 MSK 2019
---
apt/apt-pkg/cachefile.cc | 12 ++++++++++++
apt/apt-pkg/pkgcachegen.cc | 12 ++++++++++++
2 files changed, 24 insertions(+)
diff --git a/apt/apt-pkg/cachefile.cc b/apt/apt-pkg/cachefile.cc
index 1a5fa64..0ac882b 100644
--- a/apt/apt-pkg/cachefile.cc
+++ b/apt/apt-pkg/cachefile.cc
@@ -81,6 +81,12 @@ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
return false;
// Read the caches
+ if (Map != nullptr)
+ {
+ delete Map;
+ Map = nullptr;
+ }
+
bool Res = pkgMakeStatusCache(*SrcList,Progress,&Map,!WithLock);
Progress.Done();
if (Res == false)
@@ -90,6 +96,12 @@ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
if (_error->empty() == false)
_error->Warning(_("You may want to run apt-get update to correct these problems"));
+ if (Cache != nullptr)
+ {
+ delete Cache;
+ Cache = nullptr;
+ }
+
Cache = new pkgCache(Map);
if (_error->PendingError() == true)
return false;
diff --git a/apt/apt-pkg/pkgcachegen.cc b/apt/apt-pkg/pkgcachegen.cc
index 654c81c..42f2d42 100644
--- a/apt/apt-pkg/pkgcachegen.cc
+++ b/apt/apt-pkg/pkgcachegen.cc
@@ -834,7 +834,14 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
}
if (OutMap != 0)
+ {
+ if (*OutMap != nullptr)
+ {
+ delete *OutMap;
+ }
+
*OutMap = Map.UnGuard();
+ }
return true;
}
/*}}}*/
@@ -1130,6 +1137,11 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
return false;
if (OutMap != 0)
{
+ if (*OutMap != nullptr)
+ {
+ delete *OutMap;
+ }
+
if (CacheF != 0)
{
delete Map.UnGuard();
--
2.24.0
Подробная информация о списке рассылки Devel