diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-06-18 17:33:15 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-08-10 17:25:25 +0200 |
commit | 3d8232bf97ce11818fb07813a71136484ea1a44a (patch) | |
tree | c7e1e3885e952f7ab8171e1cf4b425ddccb5606f /cmdline | |
parent | c3392a9fccc04129816057b1184c651171034376 (diff) |
fix memory leaks reported by -fsanitize
Various small leaks here and there. Nothing particularily big, but still
good to fix. Found by the sanitizers while running our testcases.
Reported-By: gcc -fsanitize
Git-Dch: Ignore
Diffstat (limited to 'cmdline')
-rw-r--r-- | cmdline/apt-cache.cc | 1 | ||||
-rw-r--r-- | cmdline/apt-get.cc | 8 |
2 files changed, 4 insertions, 5 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 303605f70..9c884433c 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1484,6 +1484,7 @@ static bool Search(CommandLine &CmdL) delete [] PatternMatch; for (unsigned I = 0; I != NumPatterns; I++) regfree(&Patterns[I]); + delete [] Patterns; if (ferror(stdout)) return _error->Error("Write to stdout failed"); return true; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 184b51d23..632c7cfea 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1015,9 +1015,6 @@ static bool DoBuildDep(CommandLine &CmdL) pkgSourceList *List = Cache.GetSourceList(); // Create the text record parsers -#if APT_PKG_ABI < 413 - pkgRecords Recs(Cache); -#endif pkgSrcRecords SrcRecs(*List); if (_error->PendingError() == true) return false; @@ -1039,6 +1036,7 @@ static bool DoBuildDep(CommandLine &CmdL) { string Src; pkgSrcRecords::Parser *Last = 0; + SPtr<pkgSrcRecords::Parser> LastOwner; // an unpacked debian source tree using APT::String::Startswith; @@ -1050,7 +1048,7 @@ static bool DoBuildDep(CommandLine &CmdL) std::string TypeName = "debian/control File Source Index"; pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str()); if(Type != NULL) - Last = Type->CreateSrcPkgParser(*I); + LastOwner = Last = Type->CreateSrcPkgParser(*I); } // if its a local file (e.g. .dsc) use this else if (FileExists(*I)) @@ -1061,7 +1059,7 @@ static bool DoBuildDep(CommandLine &CmdL) string TypeName = flExtension(*I) + " File Source Index"; pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str()); if(Type != NULL) - Last = Type->CreateSrcPkgParser(*I); + LastOwner = Last = Type->CreateSrcPkgParser(*I); } else { // normal case, search the cache for the source file #if APT_PKG_ABI >= 413 |