diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-03-25 13:08:06 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-04-03 14:44:47 +0200 |
commit | c48ef8942d87388a67af9e2cad92171aca3be731 (patch) | |
tree | d9f0fcbbb197d26bf1912c3735cd9a21e2f97f19 /apt-pkg/deb/debindexfile.cc | |
parent | 46c4043d741cb2c1d54e7f5bfaa234f1b7580f6c (diff) |
don't leak on error in listparser creation
Git-Dch: Ignore
Reported-By: gcc -fsanitize=address
Diffstat (limited to 'apt-pkg/deb/debindexfile.cc')
-rw-r--r-- | apt-pkg/deb/debindexfile.cc | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 84dabc06b..9be2db4c9 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -121,12 +121,18 @@ std::string debTranslationsIndex::GetArchitecture() const pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg) { if (Pkg.IsOpen() == false) - return NULL; + return nullptr; _error->PushToStack(); pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg); bool const newError = _error->PendingError(); _error->MergeWithStack(); - return newError ? NULL : Parser; + if (newError) + { + delete Parser; + return nullptr; + } + else + return Parser; } /*}}}*/ // dpkg/status Index /*{{{*/ @@ -149,12 +155,18 @@ uint8_t debStatusIndex::GetIndexFlags() const pkgCacheListParser * debStatusIndex::CreateListParser(FileFd &Pkg) { if (Pkg.IsOpen() == false) - return NULL; + return nullptr; _error->PushToStack(); pkgCacheListParser * const Parser = new debStatusListParser(&Pkg); bool const newError = _error->PendingError(); _error->MergeWithStack(); - return newError ? NULL : Parser; + if (newError) + { + delete Parser; + return nullptr; + } + else + return Parser; } /*}}}*/ // DebPkgFile Index - a single .deb file as an index /*{{{*/ @@ -225,12 +237,18 @@ bool debDebPkgFileIndex::OpenListFile(FileFd &Pkg, std::string const &FileName) pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg) { if (Pkg.IsOpen() == false) - return NULL; + return nullptr; _error->PushToStack(); pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile); bool const newError = _error->PendingError(); _error->MergeWithStack(); - return newError ? NULL : Parser; + if (newError) + { + delete Parser; + return nullptr; + } + else + return Parser; } uint8_t debDebPkgFileIndex::GetIndexFlags() const { |