diff options
Diffstat (limited to 'apt-private')
-rw-r--r-- | apt-private/private-cacheset.cc | 13 | ||||
-rw-r--r-- | apt-private/private-depends.cc | 4 | ||||
-rw-r--r-- | apt-private/private-list.cc | 4 | ||||
-rw-r--r-- | apt-private/private-show.cc | 14 |
4 files changed, 23 insertions, 12 deletions
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index 981766cdf..52cd22d2a 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -30,13 +30,18 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, Matcher &matcher, OpProgress * const progress) { - pkgCache *Cache = CacheFile.GetPkgCache(); - pkgDepCache *DepCache = CacheFile.GetDepCache(); + pkgCache * const Cache = CacheFile.GetPkgCache(); + if (unlikely(Cache == nullptr)) + return false; + if (progress != nullptr) + progress->SubProgress(Cache->Head().PackageCount, _("Sorting")); + + pkgDepCache * const DepCache = CacheFile.GetDepCache(); + if (unlikely(DepCache == nullptr)) + return false; APT::CacheSetHelper helper(false); int Done=0; - if (progress != NULL) - progress->SubProgress(Cache->Head().PackageCount, _("Sorting")); bool const insertCurrentVer = _config->FindB("APT::Cmd::Installed", false); bool const insertUpgradable = _config->FindB("APT::Cmd::Upgradable", false); diff --git a/apt-private/private-depends.cc b/apt-private/private-depends.cc index 955f3dc67..3a3a2737a 100644 --- a/apt-private/private-depends.cc +++ b/apt-private/private-depends.cc @@ -26,8 +26,8 @@ static bool ShowDepends(CommandLine &CmdL, bool const RevDepends) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - if (unlikely(Cache == NULL)) + pkgCache * const Cache = CacheFile.GetPkgCache(); + if (unlikely(Cache == nullptr || CacheFile.GetDepCache() == nullptr)) return false; CacheSetHelperVirtuals helper(false); diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc index a948c7d9f..32c8eeaa2 100644 --- a/apt-private/private-list.cc +++ b/apt-private/private-list.cc @@ -93,8 +93,8 @@ static void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,/*{{{*/ bool DoList(CommandLine &Cmd) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - if (unlikely(Cache == NULL)) + pkgCache * const Cache = CacheFile.GetPkgCache(); + if (unlikely(Cache == nullptr || CacheFile.GetDepCache() == nullptr)) return false; pkgRecords records(CacheFile); diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc index d28387ba9..03229476e 100644 --- a/apt-private/private-show.cc +++ b/apt-private/private-show.cc @@ -258,6 +258,8 @@ bool ShowPackage(CommandLine &CmdL) /*{{{*/ CacheSetHelperVirtuals helper(true, GlobalError::NOTICE); APT::CacheSetHelper::VerSelector const select = _config->FindB("APT::Cache::AllVersions", true) ? APT::CacheSetHelper::ALL : APT::CacheSetHelper::CANDIDATE; + if (select == APT::CacheSetHelper::CANDIDATE && CacheFile.GetDepCache() == nullptr) + return false; APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper); int const ShowVersion = _config->FindI("APT::Cache::Show::Version", 1); for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver) @@ -356,10 +358,14 @@ bool ShowSrcPackage(CommandLine &CmdL) /*{{{*/ bool Policy(CommandLine &CmdL) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - pkgPolicy *Plcy = CacheFile.GetPolicy(); - pkgSourceList *SrcList = CacheFile.GetSourceList(); - if (unlikely(Cache == NULL || Plcy == NULL || SrcList == NULL)) + pkgSourceList const * const SrcList = CacheFile.GetSourceList(); + if (unlikely(SrcList == nullptr)) + return false; + pkgCache * const Cache = CacheFile.GetPkgCache(); + if (unlikely(Cache == nullptr)) + return false; + pkgPolicy * const Plcy = CacheFile.GetPolicy(); + if (unlikely(Plcy == nullptr)) return false; // Print out all of the package files |