Re: Memory leaks in apt
[argh... <insert really bad rant here> ... sry for the noise]
Hello again...
The previously attached patch was an older version and
e.g. a segfaults while regenerating the caches.
So, a patch for the patch:
=== modified file 'apt-pkg/metaindex.h'
--- apt-pkg/metaindex.h 2009-06-16 13:16:15 +0000
+++ apt-pkg/metaindex.h 2009-06-16 14:23:25 +0000
@@ -40,6 +40,8 @@
virtual bool IsTrusted() const = 0;
virtual ~metaIndex() {
+ if (Indexes == 0)
+ return;
for (vector<pkgIndexFile *>::iterator I = (*Indexes).begin(); I
!= (*Indexes).end(); ++I)
delete *I;
delete Indexes;
Again, sorry for the noise... i will hang myself with a nullpointer now...
Best regards / Mit freundlichen Grüßen,
David "DonKult" Kalnischkies
=== modified file 'apt-pkg/deb/debmetaindex.cc'
--- apt-pkg/deb/debmetaindex.cc 2008-11-16 13:58:02 +0000
+++ apt-pkg/deb/debmetaindex.cc 2009-06-16 13:16:15 +0000
@@ -115,6 +115,13 @@
this->Type = "deb";
}
+debReleaseIndex::~debReleaseIndex()
+{
+ for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
+ I != SectionEntries.end(); I++)
+ delete *I;
+}
+
vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const
{
vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;
=== modified file 'apt-pkg/deb/debmetaindex.h'
--- apt-pkg/deb/debmetaindex.h 2006-12-14 11:39:29 +0000
+++ apt-pkg/deb/debmetaindex.h 2009-06-16 13:16:15 +0000
@@ -22,6 +22,7 @@
public:
debReleaseIndex(string URI, string Dist);
+ ~debReleaseIndex();
virtual string ArchiveURI(string File) const {return URI + File;};
virtual bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;
=== modified file 'apt-pkg/deb/debsrcrecords.cc'
--- apt-pkg/deb/debsrcrecords.cc 2008-11-16 13:58:02 +0000
+++ apt-pkg/deb/debsrcrecords.cc 2009-06-16 13:16:15 +0000
@@ -152,3 +152,11 @@
return true;
}
/*}}}*/
+// SrcRecordParser::~SrcRecordParser - Destructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+debSrcRecordParser::~debSrcRecordParser()
+{
+ delete[] Buffer;
+}
+ /*}}}*/
=== modified file 'apt-pkg/deb/debsrcrecords.h'
--- apt-pkg/deb/debsrcrecords.h 2008-11-16 13:58:02 +0000
+++ apt-pkg/deb/debsrcrecords.h 2009-06-16 13:16:15 +0000
@@ -50,6 +50,7 @@
debSrcRecordParser(string File,pkgIndexFile const *Index)
: Parser(Index), Fd(File,FileFd::ReadOnly), Tags(&Fd,102400),
Buffer(0), BufSize(0) {}
+ ~debSrcRecordParser();
};
#endif
=== modified file 'apt-pkg/metaindex.h'
--- apt-pkg/metaindex.h 2006-12-14 11:39:29 +0000
+++ apt-pkg/metaindex.h 2009-06-16 14:33:58 +0000
@@ -39,7 +39,13 @@
virtual vector<pkgIndexFile *> *GetIndexFiles() = 0;
virtual bool IsTrusted() const = 0;
- virtual ~metaIndex() {};
+ virtual ~metaIndex() {
+ if (Indexes == 0)
+ return;
+ for (vector<pkgIndexFile *>::iterator I = (*Indexes).begin(); I != (*Indexes).end(); ++I)
+ delete *I;
+ delete Indexes;
+ }
};
#endif
=== modified file 'cmdline/apt-get.cc'
--- cmdline/apt-get.cc 2009-06-13 16:00:57 +0000
+++ cmdline/apt-get.cc 2009-06-16 13:16:15 +0000
@@ -111,6 +111,9 @@
return Open(true);
}
CacheFile() : List(0) {};
+ ~CacheFile() {
+ delete[] List;
+ }
};
/*}}}*/
// IsAutoInstallOk - implements a few MarkInstall package checks /*{{{*/
Reply to: