diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/deb/debindexfile.cc | 30 | ||||
-rw-r--r-- | apt-pkg/indexfile.cc | 10 |
2 files changed, 32 insertions, 8 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 { diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 657cdfb36..894671bae 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -325,12 +325,18 @@ pkgDebianIndexFile::~pkgDebianIndexFile() pkgCacheListParser * pkgDebianIndexFile::CreateListParser(FileFd &Pkg) { if (Pkg.IsOpen() == false) - return NULL; + return nullptr; _error->PushToStack(); pkgCacheListParser * const Parser = new debListParser(&Pkg); bool const newError = _error->PendingError(); _error->MergeWithStack(); - return newError ? NULL : Parser; + if (newError) + { + delete Parser; + return nullptr; + } + else + return Parser; } bool pkgDebianIndexFile::Merge(pkgCacheGenerator &Gen,OpProgress * const Prog) { |